diff options
Diffstat (limited to 'src/libjin/Thread')
-rw-r--r-- | src/libjin/Thread/Thread.cpp | 36 | ||||
-rw-r--r-- | src/libjin/Thread/Thread.h | 18 | ||||
-rw-r--r-- | src/libjin/Thread/thread.cpp | 36 | ||||
-rw-r--r-- | src/libjin/Thread/thread.h | 18 |
4 files changed, 54 insertions, 54 deletions
diff --git a/src/libjin/Thread/Thread.cpp b/src/libjin/Thread/Thread.cpp index 13e691a..c2b7b91 100644 --- a/src/libjin/Thread/Thread.cpp +++ b/src/libjin/Thread/Thread.cpp @@ -1,5 +1,5 @@ #include "../modules.h" -#if JIN_MODULES_THREAD +#if LIBJIN_MODULES_THREAD #include "Thread.h" @@ -17,7 +17,7 @@ namespace thread void lock(); void unlock(); private: - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_mutex* mutex; #endif friend class Conditional; @@ -33,7 +33,7 @@ namespace thread void broadcast(); bool wait(Mutex* mutex, int timeout = -1); private: - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_cond* cond; #endif }; @@ -63,28 +63,28 @@ namespace thread Mutex::Mutex() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL mutex = SDL_CreateMutex(); #endif } Mutex::~Mutex() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_DestroyMutex(mutex); #endif } void Mutex::lock() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_LockMutex(mutex); #endif } void Mutex::unlock() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_UnlockMutex(mutex); #endif } @@ -93,35 +93,35 @@ namespace thread Conditional::Conditional() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL cond = SDL_CreateCond(); #endif } Conditional::~Conditional() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_DestroyCond(cond); #endif } void Conditional::signal() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_CondSignal(cond); #endif } void Conditional::broadcast() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_CondBroadcast(cond); #endif } bool Conditional::wait(Mutex* mutex, int timeout) { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL if (timeout < 0) return !SDL_CondWait(cond, mutex->mutex); else @@ -183,7 +183,7 @@ namespace thread Thread::~Thread() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL #endif } @@ -206,13 +206,13 @@ namespace thread return false; if (handle) { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_WaitThread(handle, nullptr); #endif } - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL handle = SDL_CreateThread(threadRunner, name.c_str(), p); - #elif JIN_THREAD_CPP + #elif LIBJIN_THREAD_CPP handle = new std::thread(); #endif return (running = (handle != nullptr)); @@ -225,7 +225,7 @@ namespace thread if (!handle) return; } - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_WaitThread(handle, nullptr); #endif Lock l(mutex); @@ -298,4 +298,4 @@ namespace thread } // thread } // jin -#endif // JIN_MODULES_THREAD
\ No newline at end of file +#endif // LIBJIN_MODULES_THREAD
\ No newline at end of file diff --git a/src/libjin/Thread/Thread.h b/src/libjin/Thread/Thread.h index 3300b4f..3c41949 100644 --- a/src/libjin/Thread/Thread.h +++ b/src/libjin/Thread/Thread.h @@ -1,13 +1,13 @@ -#ifndef __JIN_THREAD_H -#define __JIN_THREAD_H +#ifndef __LIBJIN_THREAD_H +#define __LIBJIN_THREAD_H #include "../modules.h" -#if JIN_MODULES_THREAD +#if LIBJIN_MODULES_THREAD #include <string> #include <map> -#if JIN_THREAD_SDL +#if LIBJIN_THREAD_SDL # include "SDL2/SDL_thread.h" -#elif JIN_THREAD_CPP +#elif LIBJIN_THREAD_CPP # include <thread> # include <mutex> # include <condition_variable> @@ -116,9 +116,9 @@ namespace thread void unlock(); protected: - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_Thread* handle; // SDL thread - #elif JIN_THREAD_CPP + #elif LIBJIN_THREAD_CPP std::thread* handle; // cpp thread #endif Mutex* mutex; // mutex variable @@ -162,5 +162,5 @@ namespace thread } // thread } // jin -#endif // JIN_MODULES_THREAD -#endif // __JIN_THREAD_H
\ No newline at end of file +#endif // LIBJIN_MODULES_THREAD +#endif // __LIBJIN_THREAD_H
\ No newline at end of file diff --git a/src/libjin/Thread/thread.cpp b/src/libjin/Thread/thread.cpp index 13e691a..c2b7b91 100644 --- a/src/libjin/Thread/thread.cpp +++ b/src/libjin/Thread/thread.cpp @@ -1,5 +1,5 @@ #include "../modules.h" -#if JIN_MODULES_THREAD +#if LIBJIN_MODULES_THREAD #include "Thread.h" @@ -17,7 +17,7 @@ namespace thread void lock(); void unlock(); private: - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_mutex* mutex; #endif friend class Conditional; @@ -33,7 +33,7 @@ namespace thread void broadcast(); bool wait(Mutex* mutex, int timeout = -1); private: - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_cond* cond; #endif }; @@ -63,28 +63,28 @@ namespace thread Mutex::Mutex() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL mutex = SDL_CreateMutex(); #endif } Mutex::~Mutex() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_DestroyMutex(mutex); #endif } void Mutex::lock() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_LockMutex(mutex); #endif } void Mutex::unlock() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_UnlockMutex(mutex); #endif } @@ -93,35 +93,35 @@ namespace thread Conditional::Conditional() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL cond = SDL_CreateCond(); #endif } Conditional::~Conditional() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_DestroyCond(cond); #endif } void Conditional::signal() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_CondSignal(cond); #endif } void Conditional::broadcast() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_CondBroadcast(cond); #endif } bool Conditional::wait(Mutex* mutex, int timeout) { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL if (timeout < 0) return !SDL_CondWait(cond, mutex->mutex); else @@ -183,7 +183,7 @@ namespace thread Thread::~Thread() { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL #endif } @@ -206,13 +206,13 @@ namespace thread return false; if (handle) { - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_WaitThread(handle, nullptr); #endif } - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL handle = SDL_CreateThread(threadRunner, name.c_str(), p); - #elif JIN_THREAD_CPP + #elif LIBJIN_THREAD_CPP handle = new std::thread(); #endif return (running = (handle != nullptr)); @@ -225,7 +225,7 @@ namespace thread if (!handle) return; } - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_WaitThread(handle, nullptr); #endif Lock l(mutex); @@ -298,4 +298,4 @@ namespace thread } // thread } // jin -#endif // JIN_MODULES_THREAD
\ No newline at end of file +#endif // LIBJIN_MODULES_THREAD
\ No newline at end of file diff --git a/src/libjin/Thread/thread.h b/src/libjin/Thread/thread.h index 3300b4f..3c41949 100644 --- a/src/libjin/Thread/thread.h +++ b/src/libjin/Thread/thread.h @@ -1,13 +1,13 @@ -#ifndef __JIN_THREAD_H -#define __JIN_THREAD_H +#ifndef __LIBJIN_THREAD_H +#define __LIBJIN_THREAD_H #include "../modules.h" -#if JIN_MODULES_THREAD +#if LIBJIN_MODULES_THREAD #include <string> #include <map> -#if JIN_THREAD_SDL +#if LIBJIN_THREAD_SDL # include "SDL2/SDL_thread.h" -#elif JIN_THREAD_CPP +#elif LIBJIN_THREAD_CPP # include <thread> # include <mutex> # include <condition_variable> @@ -116,9 +116,9 @@ namespace thread void unlock(); protected: - #if JIN_THREAD_SDL + #if LIBJIN_THREAD_SDL SDL_Thread* handle; // SDL thread - #elif JIN_THREAD_CPP + #elif LIBJIN_THREAD_CPP std::thread* handle; // cpp thread #endif Mutex* mutex; // mutex variable @@ -162,5 +162,5 @@ namespace thread } // thread } // jin -#endif // JIN_MODULES_THREAD -#endif // __JIN_THREAD_H
\ No newline at end of file +#endif // LIBJIN_MODULES_THREAD +#endif // __LIBJIN_THREAD_H
\ No newline at end of file |