mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Cleanup jthread and fix win32 build
This commit is contained in:
parent
f3439c40d8
commit
04e9a9d541
29 changed files with 185 additions and 194 deletions
|
@ -53,10 +53,8 @@ class JMutex
|
|||
public:
|
||||
JMutex();
|
||||
~JMutex();
|
||||
int Init();
|
||||
int Lock();
|
||||
int Unlock();
|
||||
bool IsInitialized() { return initialized; }
|
||||
|
||||
private:
|
||||
#if (defined(WIN32) || defined(_WIN32_WCE))
|
||||
|
@ -76,57 +74,6 @@ private:
|
|||
return false;
|
||||
}
|
||||
#endif // WIN32
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue