diff options
Diffstat (limited to 'src/libjin/multithread/je_thread.cpp')
-rw-r--r-- | src/libjin/multithread/je_thread.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/libjin/multithread/je_thread.cpp b/src/libjin/multithread/je_thread.cpp index 3c18657..0c528bf 100644 --- a/src/libjin/multithread/je_thread.cpp +++ b/src/libjin/multithread/je_thread.cpp @@ -1,5 +1,5 @@ #include "../core/je_configuration.h" -#if LIBJIN_MODULES_THREAD +#if defined(jin_thread) #include "je_thread.h" @@ -17,7 +17,7 @@ namespace JinEngine void lock(); void unlock(); private: - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_mutex* mutex; #endif friend class Conditional; @@ -33,7 +33,7 @@ namespace JinEngine void broadcast(); bool wait(Mutex* mutex, int timeout = -1); private: - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_cond* cond; #endif }; @@ -63,28 +63,28 @@ namespace JinEngine Mutex::Mutex() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl mutex = SDL_CreateMutex(); #endif } Mutex::~Mutex() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_DestroyMutex(mutex); #endif } void Mutex::lock() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_LockMutex(mutex); #endif } void Mutex::unlock() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_UnlockMutex(mutex); #endif } @@ -93,35 +93,35 @@ namespace JinEngine Conditional::Conditional() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl cond = SDL_CreateCond(); #endif } Conditional::~Conditional() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_DestroyCond(cond); #endif } void Conditional::signal() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_CondSignal(cond); #endif } void Conditional::broadcast() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_CondBroadcast(cond); #endif } bool Conditional::wait(Mutex* mutex, int timeout) { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl if (timeout < 0) return !SDL_CondWait(cond, mutex->mutex); else @@ -183,7 +183,7 @@ namespace JinEngine Thread::~Thread() { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl #endif } @@ -206,13 +206,13 @@ namespace JinEngine return false; if (handle) { - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_WaitThread(handle, nullptr); #endif } - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl handle = SDL_CreateThread(threadRunner, name.c_str(), p); - #elif LIBJIN_THREAD_CPP + #elif jin_thread == jin_thread_cpp handle = new std::thread(); #endif return (running = (handle != nullptr)); @@ -225,7 +225,7 @@ namespace JinEngine if (!handle) return; } - #if LIBJIN_THREAD_SDL + #if jin_thread == jin_thread_sdl SDL_WaitThread(handle, nullptr); #endif Lock l(mutex); @@ -298,4 +298,4 @@ namespace JinEngine } // namespace MultiThread } // namespace JinEngine -#endif // LIBJIN_MODULES_THREAD
\ No newline at end of file +#endif // defined(jin_thread)
\ No newline at end of file |