This makes some parts of #53 unnecessary, sorry Fela
This commit is contained in:
Grishka
2018-09-16 23:38:52 +03:00
parent 9a1ec510e2
commit 14d782bf9f
15 changed files with 26 additions and 3 deletions

View File

@@ -6,6 +6,7 @@
#include <time.h>
#include <math.h>
#include <float.h>
#include <stdint.h>
#ifndef _WIN32
#include <sys/time.h>
@@ -22,7 +23,11 @@ MessageThread::MessageThread() : Thread(new MethodPointer<MessageThread>(&Messag
SetName("MessageThread");
#ifdef _WIN32
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP
event=CreateEvent(NULL, false, false, NULL);
#else
event=CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS);
#endif
#else
pthread_cond_init(&cond, NULL);
#endif
@@ -59,7 +64,11 @@ void MessageThread::Run(void* arg){
#ifdef _WIN32
queueMutex.Unlock();
DWORD actualWaitTimeout=waitTimeout==DBL_MAX ? INFINITE : ((DWORD)round(waitTimeout*1000.0));
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP
WaitForSingleObject(event, actualWaitTimeout);
#else
WaitForSingleObjectEx(event, actualWaitTimeout, false);
#endif
// we don't really care if a context switch happens here and anything gets added to the queue by another thread
// since any new no-delay messages will get delivered on this iteration anyway
queueMutex.Lock();