diff --git a/JGE/include/Threading.h b/JGE/include/Threading.h index 2c0667ce7..73036a27d 100644 --- a/JGE/include/Threading.h +++ b/JGE/include/Threading.h @@ -1,7 +1,7 @@ #ifndef THREADING_H #define THREADING_H -#if !defined(PSP) && !defined(QT_CONFIG) +#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L) #include #ifdef WIN32 @@ -14,7 +14,7 @@ #endif #include -#elif !defined(QT_CONFIG) +#elif defined(PSP) #include #include @@ -26,7 +26,7 @@ namespace boost { /** - ** PSP specific variant of a boost mutex & scoped_lock + ** PSP specific variant of a boost mutex & scoped_lock */ template @@ -60,7 +60,7 @@ namespace boost { sceKernelDeleteSema(mID); } - + void lock() { int result = sceKernelWaitSema(mID, 1, 0); @@ -142,7 +142,7 @@ namespace boost } } - + int mID; int mThreadID; volatile int mRecursionCount; @@ -164,7 +164,7 @@ namespace boost /** - ** Emulating boost::thread configuration glue, with some shortcuts + ** Emulating boost::thread configuration glue, with some shortcuts ** This detail namespace is a distillation of boost's thread.hpp, thread_data.hpp. */ namespace detail @@ -212,13 +212,13 @@ namespace boost ** ** The intent of its usage is this form only: ** mWorkerThread = boost::thread(ThreadProc, this); - ** where ThreadProc is a static member function of the 'this' class,eg: - ** static void FOO::ThreadProc(void* inParam) - ** { - ** FOO* instance = reinterpret_cast(inParam); - ** // now you have class instance data available... - ** } - ** + ** where ThreadProc is a static member function of the 'this' class,eg: + ** static void FOO::ThreadProc(void* inParam) + ** { + ** FOO* instance = reinterpret_cast(inParam); + ** // now you have class instance data available... + ** } + ** ** Any other variant of a thread proc with more than one param is unimplemented. */ class thread @@ -227,7 +227,7 @@ namespace boost ** Helper class for sceKernelStartThread, which passes args by value, not by reference ** We use this struct to wrap any pointers that we want to pass to the worker thread. */ - struct CallbackData + struct CallbackData { CallbackData(detail::thread_data_ptr inThreadInfo) : mThreadInfo(inThreadInfo) @@ -307,7 +307,7 @@ namespace boost } } -#elif defined(QT_CONFIG) +#elif defined(QT_CONFIG) && (__cplusplus <= 199711L) #include #include @@ -537,6 +537,80 @@ namespace boost } } +#elif (__cplusplus > 199711L) + +#include +#include + +namespace boost +{ + typedef std::thread thread; + + template + struct unique_lock + { + unique_lock(Mutex& inMutex) : mMutex(&inMutex) + { + mMutex->lock(); + } + + ~unique_lock() + { + mMutex->unlock(); + } + + Mutex* mMutex; + }; + + class mutex + { + public: + + typedef unique_lock scoped_lock; + + mutex() + : mQMutex() + { + } + + ~mutex() + { + } + + void lock() + { + mQMutex.lock(); + } + + void unlock() + { + mQMutex.unlock(); + } + + std::mutex mQMutex; + + private: + mutex(mutex const&); + mutex& operator=(mutex const&); + }; + + namespace posix_time + { + typedef unsigned int milliseconds; + } + + /** + ** boost's platform neutral sleep call. + */ + namespace this_thread + { + inline void sleep(boost::posix_time::milliseconds const& time) + { + std::this_thread::sleep_for(std::chrono::milliseconds(time)); + } + } +} + #endif #endif // THREADING_H