<< scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "else\n"
<< scope_tab << scope_tab << scope_tab << "{\n"
- << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(this._cb_free_cb, this._cb_data);\n"
+ << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.ThreadSafeFreeCbExec(this._cb_free_cb, this._cb_data);\n"
<< scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << scope_tab << "this._cb_free_cb = null;\n"
<< scope_tab << scope_tab << scope_tab << "this._cb_data = IntPtr.Zero;\n"
<< scope_tab << scope_tab << scope_tab << "else\n"
<< scope_tab << scope_tab << scope_tab << "{\n"
- << scope_tab << scope_tab << scope_tab << scope_tab << "Monitor.Enter(Efl.Eo.Config.InitLock);\n"
- << scope_tab << scope_tab << scope_tab << scope_tab << "if (Efl.Eo.Config.Initialized)\n"
+ << scope_tab << scope_tab << scope_tab << scope_tab << "Monitor.Enter(Efl.All.InitLock);\n"
+ << scope_tab << scope_tab << scope_tab << scope_tab << "if (Efl.All.MainLoopInitialized)\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_mono_thread_safe_native_dispose(h, gcHandlePtr);\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "}\n\n"
- << scope_tab << scope_tab << scope_tab << scope_tab << "Monitor.Exit(Efl.Eo.Config.InitLock);\n"
+ << scope_tab << scope_tab << scope_tab << scope_tab << "Monitor.Exit(Efl.All.InitLock);\n"
<< scope_tab << scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n\n"
{
private static bool InitializedUi = false;
+ public static bool MainLoopInitialized {
+ get;
+ private set;
+ }
+
+ public static readonly object InitLock = new object();
+
public static void Init(Efl.Csharp.Components components = Efl.Csharp.Components.Basic)
{
Eina.Config.Init();
Efl.Ui.Config.Init();
InitializedUi = true;
}
+ Monitor.Enter(InitLock);
+ MainLoopInitialized = true;
+ Monitor.Exit(InitLock);
}
/// <summary>Shutdowns all EFL subsystems.</summary>
public static void Shutdown()
{
// Try to cleanup everything before actually shutting down.
+ Eina.Log.Debug("Calling GC before shutdown");
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
+ Monitor.Enter(InitLock);
+ MainLoopInitialized = false;
+ Monitor.Exit(InitLock);
+
if (InitializedUi)
{
+ Eina.Log.Debug("Shutting down Elementary");
Efl.Ui.Config.Shutdown();
}
+ Eina.Log.Debug("Shutting down Eldbus");
eldbus.Config.Shutdown();
+ Eina.Log.Debug("Shutting down Evas");
evas_shutdown();
+ Eina.Log.Debug("Shutting down Ecore");
ecore_shutdown();
+ Eina.Log.Debug("Shutting down Eo");
Efl.Eo.Config.Shutdown();
+ Eina.Log.Debug("Shutting down Eina");
Eina.Config.Shutdown();
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_accessor_free, Handle);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_accessor_free, Handle);
}
Handle = IntPtr.Zero;
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_array_free, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_array_free, h);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_binbuf_free, Handle);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_binbuf_free, Handle);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_hash_free, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_hash_free, h);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_inarray_free, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_inarray_free, h);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_iterator_free, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_iterator_free, h);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_strbuf_free, Handle);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_strbuf_free, Handle);
}
Handle = IntPtr.Zero;
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_value_free, this.Handle);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_value_free, this.Handle);
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_connection_unref, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eldbus_connection_unref, h);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_message_unref, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eldbus_message_unref, h);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_object_unref, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eldbus_object_unref, h);
}
}
}
}
else
{
- Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eldbus_proxy_unref, h);
+ Efl.Eo.Globals.ThreadSafeFreeCbExec(eldbus_proxy_unref, h);
}
}
}
efl_mono_thread_safe_efl_unref(IntPtr eo);
[DllImport(efl.Libs.CustomExports)] public static extern void
- efl_mono_thread_safe_free_cb_exec(EinaFreeCb free_cb, IntPtr cb_data);
+ efl_mono_thread_safe_free_cb_exec(IntPtr free_cb, IntPtr cb_data);
[DllImport(efl.Libs.Eo)] public static extern IntPtr
efl_class_name_get(IntPtr eo);
return ret;
}
+ private static Efl.FreeGCHandleCb FreeGCHandleCallbackDelegate = new Efl.FreeGCHandleCb(FreeGCHandleCallback);
public static void FreeGCHandleCallback(IntPtr gcHandlePtr)
{
try
}
}
+ private static Efl.RemoveEventsCb RemoveEventsCallbackDelegate = new Efl.RemoveEventsCb(RemoveEventsCallback);
public static void RemoveEventsCallback(IntPtr obj, IntPtr gcHandlePtr)
{
try
public static void SetNativeDisposeCallbacks()
{
- efl_mono_gchandle_callbacks_set(FreeGCHandleCallback, RemoveEventsCallback);
+ efl_mono_gchandle_callbacks_set(FreeGCHandleCallbackDelegate, RemoveEventsCallbackDelegate);
}
-} // Globals
+ public static void ThreadSafeFreeCbExec(EinaFreeCb cbFreeCb, IntPtr cbData)
+ {
+ EinaFreeCb cb = (IntPtr gcHandlePtr) => {
+ cbFreeCb(cbData);
+ GCHandle gcHandle = GCHandle.FromIntPtr(gcHandlePtr);
+ gcHandle.Free();
+ };
-public static class Config
-{
+ Monitor.Enter(Efl.All.InitLock);
+ if (Efl.All.MainLoopInitialized)
+ {
+ IntPtr cbPtr = Marshal.GetFunctionPointerForDelegate(cb);
+ var handle = GCHandle.Alloc(cb);
+ var handlePtr = GCHandle.ToIntPtr(handle);
- public static bool Initialized {
- get;
- private set;
+ efl_mono_thread_safe_free_cb_exec(cbPtr, handlePtr);
+ }
+ Monitor.Exit(Efl.All.InitLock);
}
- public static readonly object InitLock = new object();
+} // Globals
+
+public static class Config
+{
public static void Init()
{
Globals.efl_object_init();
- Monitor.Enter(InitLock);
- Initialized = true;
- Monitor.Exit(InitLock);
Globals.SetNativeDisposeCallbacks();
}
public static void Shutdown()
{
- Monitor.Enter(InitLock);
- Initialized = false;
- Monitor.Exit(InitLock);
Globals.efl_object_shutdown();
}
}