Browse Source

Move IsMainThread to AtomicNET and make it accessible

Josh Engebretson 8 years ago
parent
commit
8d69ad8139

+ 12 - 0
Script/AtomicNET/AtomicNET/Core/AtomicNET.cs

@@ -67,6 +67,14 @@ namespace AtomicEngine
             NativeCore.RunGC();
             NativeCore.RunGC();
         }
         }
 
 
+        /// <summary>
+        ///  Returns true if called on main engine thread, false if on another thread
+        /// </summary>
+        public static bool IsMainThread()
+        {
+            return csi_AtomicEngine_IsMainThread();
+        }
+
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         private static extern uint csi_Atomic_AtomicNET_StringToStringHash(string name);
         private static extern uint csi_Atomic_AtomicNET_StringToStringHash(string name);
 
 
@@ -131,6 +139,10 @@ namespace AtomicEngine
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         private static extern IntPtr csi_Atomic_NETCore_Initialize(EventDispatchDelegate eventDispatch, UpdateDispatchDelegate updateDispatch, RefCountedDeletedDelegate refCountedDeleted, ThrowManagedExceptionDelegate throwManagedException);
         private static extern IntPtr csi_Atomic_NETCore_Initialize(EventDispatchDelegate eventDispatch, UpdateDispatchDelegate updateDispatch, RefCountedDeletedDelegate refCountedDeleted, ThrowManagedExceptionDelegate throwManagedException);
 
 
+        [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
+        [return: MarshalAs(UnmanagedType.I1)]
+        private static extern bool csi_AtomicEngine_IsMainThread();
+
         private static Context context;
         private static Context context;
         private static Dictionary<Type, AObject> subSystems = new Dictionary<Type, AObject>();
         private static Dictionary<Type, AObject> subSystems = new Dictionary<Type, AObject>();
 
 

+ 0 - 4
Script/AtomicNET/AtomicNET/Core/NativeCore.cs

@@ -444,10 +444,6 @@ namespace AtomicEngine
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
         internal static extern void csi_AtomicEngine_ReleaseSilent(IntPtr refCounted);
         internal static extern void csi_AtomicEngine_ReleaseSilent(IntPtr refCounted);
 
 
-        [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
-        [return: MarshalAs(UnmanagedType.I1)]
-        internal static extern bool csi_AtomicEngine_IsMainThread();
-
         internal struct EventSubscription
         internal struct EventSubscription
         {
         {
             public WeakReference<AObject> Receiver;
             public WeakReference<AObject> Receiver;

+ 1 - 1
Script/AtomicNET/AtomicNET/Core/RefCounted.cs

@@ -35,7 +35,7 @@ namespace AtomicEngine
             }
             }
 
 
             // We can be called from Dispose in main thread or from finalizers, which aren't in the main thread
             // We can be called from Dispose in main thread or from finalizers, which aren't in the main thread
-            if (NativeCore.csi_AtomicEngine_IsMainThread())
+            if (AtomicNET.IsMainThread())
             {
             {
                 NativeCore.csi_AtomicEngine_ReleaseRef(handle);
                 NativeCore.csi_AtomicEngine_ReleaseRef(handle);
             }
             }