dmuratshin 9 years ago
parent
commit
61b99eae5d

+ 17 - 1
oxygine/src/core/oxygine.cpp

@@ -55,6 +55,8 @@
 #include "ios/ios.h"
 #include "ios/ios.h"
 #endif
 #endif
 
 
+#include "pthread.h"
+
 #ifdef OXYGINE_SDL
 #ifdef OXYGINE_SDL
 extern "C"
 extern "C"
 {
 {
@@ -98,6 +100,8 @@ namespace oxygine
 
 
     spEventDispatcher _dispatcher;
     spEventDispatcher _dispatcher;
 
 
+    static pthread_t _mainThread;
+
 #ifdef __S3E__
 #ifdef __S3E__
 
 
     int32 pointerEvent(void* sysData, void* u)
     int32 pointerEvent(void* sysData, void* u)
@@ -213,6 +217,15 @@ namespace oxygine
 #endif
 #endif
         }
         }
 
 
+        bool isMainThread()
+        {
+#ifdef OX_NO_MT
+            return true;
+#else
+            return pthread_equal(_mainThread, pthread_self()) != 0;
+#endif
+        }
+
 #ifdef EMSCRIPTEN
 #ifdef EMSCRIPTEN
         void SDL_handleEvent(SDL_Event& event, bool& done);
         void SDL_handleEvent(SDL_Event& event, bool& done);
         int SDL_eventsHandler(void*, SDL_Event* e)
         int SDL_eventsHandler(void*, SDL_Event* e)
@@ -419,7 +432,10 @@ namespace oxygine
 #endif
 #endif
 
 
 #endif
 #endif
-            LoadResourcesContext::init();
+
+#ifndef OX_NO_MT
+            _mainThread = pthread_self();
+#endif
             init2();
             init2();
 
 
             return 1;
             return 1;

+ 2 - 0
oxygine/src/core/oxygine.h

@@ -110,6 +110,8 @@ namespace oxygine
         bool isActive();
         bool isActive();
         bool hasFocus();
         bool hasFocus();
 
 
+        bool isMainThread();
+
 
 
 #ifdef OXYGINE_SDL
 #ifdef OXYGINE_SDL
         SDL_GLContext   getGLContext();
         SDL_GLContext   getGLContext();

+ 1 - 20
oxygine/src/res/CreateResourceContext.cpp

@@ -7,30 +7,11 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
-    static pthread_t _mainThread;
-
-
-    void LoadResourcesContext::init()
-    {
-#ifndef OX_NO_MT
-        _mainThread = pthread_self();
-#endif
-    }
-
-    bool isMainThread()
-    {
-#ifdef OX_NO_MT
-        return true;
-#else
-        return pthread_equal(_mainThread, pthread_self()) != 0;
-#endif
-    }
-
     LoadResourcesContext* LoadResourcesContext::get()
     LoadResourcesContext* LoadResourcesContext::get()
     {
     {
         LoadResourcesContext* mtcontext = &MTLoadingResourcesContext::instance;
         LoadResourcesContext* mtcontext = &MTLoadingResourcesContext::instance;
         LoadResourcesContext* scontext = &SingleThreadResourcesContext::instance;
         LoadResourcesContext* scontext = &SingleThreadResourcesContext::instance;
-        return isMainThread() ? scontext : mtcontext;
+        return core::isMainThread() ? scontext : mtcontext;
     }
     }
 
 
     CreateTextureTask::CreateTextureTask(): linearFilter(true), clamp2edge(true)
     CreateTextureTask::CreateTextureTask(): linearFilter(true), clamp2edge(true)

+ 0 - 3
oxygine/src/res/CreateResourceContext.h

@@ -6,8 +6,6 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
-    bool isMainThread();
-
     /**internal class*/
     /**internal class*/
     class XmlWalker
     class XmlWalker
     {
     {
@@ -97,7 +95,6 @@ namespace oxygine
     {
     {
     public:
     public:
         static LoadResourcesContext* get();
         static LoadResourcesContext* get();
-        static void init();
 
 
         virtual ~LoadResourcesContext() {}
         virtual ~LoadResourcesContext() {}