summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-15 00:09:29 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-15 00:09:29 -0300
commite130d808cdc84b9e74d4d929a75a04c5e2175ef3 (patch)
tree3ccfd3fe45ede20d6b019dd83cf668cb26b2bfa0
parent2272e21b3cc96966f0ece64c2cc43d7bb5fce32a (diff)
csharp: FunctionPtr wrappers are not IDisposable
Summary: They don't actually store unmanaged memory and we already rely on the GC to free them (not calling Dispose() directly through the managedCb closure, so we don't need IDisposable. Just making sure we release the Function Pointer data in the main loop as the GC runs in a different thread. Ref T8423 Depends on D10672 Reviewers: brunobelo, felipealmeida, YOhoho Reviewed By: brunobelo Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8423 Differential Revision: https://phab.enlightenment.org/D10673
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index aee11ea5a0..3b5040373f 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -72,7 +72,7 @@ struct function_pointer {
72 return false; 72 return false;
73 73
74 // Wrapper type, with callback matching the Unamanaged one 74 // Wrapper type, with callback matching the Unamanaged one
75 if (!as_generator("internal class " << f_name << "Wrapper : IDisposable\n" 75 if (!as_generator("internal class " << f_name << "Wrapper\n"
76 << "{\n\n" 76 << "{\n\n"
77 << scope_tab << "private " << f_name << "Internal _cb;\n" 77 << scope_tab << "private " << f_name << "Internal _cb;\n"
78 << scope_tab << "private IntPtr _cb_data;\n" 78 << scope_tab << "private IntPtr _cb_data;\n"
@@ -87,33 +87,12 @@ struct function_pointer {
87 87
88 << scope_tab << "~" << f_name << "Wrapper()\n" 88 << scope_tab << "~" << f_name << "Wrapper()\n"
89 << scope_tab << "{\n" 89 << scope_tab << "{\n"
90 << scope_tab << scope_tab << "Dispose(false);\n"
91 << scope_tab << "}\n\n"
92
93 << scope_tab << "protected virtual void Dispose(bool disposing)\n"
94 << scope_tab << "{\n"
95 << scope_tab << scope_tab << "if (this._cb_free_cb != null)\n" 90 << scope_tab << scope_tab << "if (this._cb_free_cb != null)\n"
96 << scope_tab << scope_tab << "{\n" 91 << scope_tab << scope_tab << "{\n"
97 << scope_tab << scope_tab << scope_tab << "if (disposing)\n" 92 << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.ThreadSafeFreeCbExec(this._cb_free_cb, this._cb_data);\n"
98 << scope_tab << scope_tab << scope_tab << "{\n"
99 << scope_tab << scope_tab << scope_tab << scope_tab << "this._cb_free_cb(this._cb_data);\n"
100 << scope_tab << scope_tab << scope_tab << "}\n"
101 << scope_tab << scope_tab << scope_tab << "else\n"
102 << scope_tab << scope_tab << scope_tab << "{\n"
103 << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.ThreadSafeFreeCbExec(this._cb_free_cb, this._cb_data);\n"
104 << scope_tab << scope_tab << scope_tab << "}\n"
105 << scope_tab << scope_tab << scope_tab << "this._cb_free_cb = null;\n"
106 << scope_tab << scope_tab << scope_tab << "this._cb_data = IntPtr.Zero;\n"
107 << scope_tab << scope_tab << scope_tab << "this._cb = null;\n"
108 << scope_tab << scope_tab << "}\n" 93 << scope_tab << scope_tab << "}\n"
109 << scope_tab << "}\n\n" 94 << scope_tab << "}\n\n"
110 95
111 << scope_tab << "public void Dispose()\n"
112 << scope_tab << "{\n"
113 << scope_tab << scope_tab << "Dispose(true);\n"
114 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
115 << scope_tab << "}\n\n"
116
117 << scope_tab << "internal " << type << " ManagedCb(" << (parameter % ", ") << ")\n" 96 << scope_tab << "internal " << type << " ManagedCb(" << (parameter % ", ") << ")\n"
118 << scope_tab << "{\n" 97 << scope_tab << "{\n"
119 << function_definition_preamble << "_cb(_cb_data, " << (argument_invocation % ", ") << ");\n" 98 << function_definition_preamble << "_cb(_cb_data, " << (argument_invocation % ", ") << ");\n"