diff options
author | Weblate <42@minetest.ru> | 2013-02-28 18:03:28 +0100 |
---|---|---|
committer | Weblate <42@minetest.ru> | 2013-02-28 18:03:28 +0100 |
commit | 22e186b4aa88b585e71500c4e9a03bf69b0b6191 (patch) | |
tree | 14c5b7a73cf144ba7cf3066caac088a200f81a72 /src/jthread/jmutex.h | |
parent | 372acf7b8eca0614a4a0da93cfbaccbcd459b36b (diff) | |
parent | d31f07bd4b83f858cce589faac56922e12ba670f (diff) | |
download | minetest-22e186b4aa88b585e71500c4e9a03bf69b0b6191.tar.gz minetest-22e186b4aa88b585e71500c4e9a03bf69b0b6191.tar.bz2 minetest-22e186b4aa88b585e71500c4e9a03bf69b0b6191.zip |
Merge remote branch 'origin/master'
Diffstat (limited to 'src/jthread/jmutex.h')
-rw-r--r-- | src/jthread/jmutex.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/jthread/jmutex.h b/src/jthread/jmutex.h index 9ce013096..e528aeb4a 100644 --- a/src/jthread/jmutex.h +++ b/src/jthread/jmutex.h @@ -30,6 +30,9 @@ #define JMUTEX_H #if (defined(WIN32) || defined(_WIN32_WCE)) + #ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 + #endif #ifndef _WIN32_WCE #include <process.h> #endif // _WIN32_WCE @@ -67,4 +70,54 @@ private: bool initialized; }; +#ifdef _WIN32 + +class Event { + HANDLE hEvent; + +public: + Event() { + hEvent = CreateEvent(NULL, 0, 0, NULL); + } + + ~Event() { + CloseHandle(hEvent); + } + + void wait() { + WaitForSingleObject(hEvent, INFINITE); + } + + void signal() { + SetEvent(hEvent); + } +}; + +#else + +#include <semaphore.h> + +class Event { + sem_t sem; + +public: + Event() { + sem_init(&sem, 0, 0); + } + + ~Event() { + sem_destroy(&sem); + } + + void wait() { + sem_wait(&sem); + } + + void signal() { + sem_post(&sem); + } +}; + +#endif + #endif // JMUTEX_H |