Change PltWaitForEvent to void return type

This commit is contained in:
Cameron Gutman 2021-06-09 19:35:55 -05:00
parent 61b4fc1fe7
commit 71a267fd28
3 changed files with 4 additions and 21 deletions

View File

@ -204,7 +204,6 @@ int LbqPollQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
int LbqWaitForQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) { int LbqWaitForQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
PLINKED_BLOCKING_QUEUE_ENTRY entry; PLINKED_BLOCKING_QUEUE_ENTRY entry;
int err;
if (queueHead->shutdown) { if (queueHead->shutdown) {
return LBQ_INTERRUPTED; return LBQ_INTERRUPTED;
@ -217,10 +216,7 @@ int LbqWaitForQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
// //
// If we're draining, we will never wait on the queue. // If we're draining, we will never wait on the queue.
if (queueHead->head == NULL && !queueHead->draining) { if (queueHead->head == NULL && !queueHead->draining) {
err = PltWaitForEvent(&queueHead->containsDataEvent); PltWaitForEvent(&queueHead->containsDataEvent);
if (err != PLT_WAIT_SUCCESS) {
return LBQ_INTERRUPTED;
}
} }
PltLockMutex(&queueHead->mutex); PltLockMutex(&queueHead->mutex);

View File

@ -329,25 +329,15 @@ void PltClearEvent(PLT_EVENT* event) {
#endif #endif
} }
int PltWaitForEvent(PLT_EVENT* event) { void PltWaitForEvent(PLT_EVENT* event) {
#if defined(LC_WINDOWS) #if defined(LC_WINDOWS)
DWORD error; WaitForSingleObjectEx(*event, INFINITE, FALSE);
error = WaitForSingleObjectEx(*event, INFINITE, FALSE);
if (error == WAIT_OBJECT_0) {
return PLT_WAIT_SUCCESS;
}
else {
LC_ASSERT(false);
return -1;
}
#else #else
PltLockMutex(&event->mutex); PltLockMutex(&event->mutex);
while (!event->signalled) { while (!event->signalled) {
PltWaitForConditionVariable(&event->cond, &event->mutex); PltWaitForConditionVariable(&event->cond, &event->mutex);
} }
PltUnlockMutex(&event->mutex); PltUnlockMutex(&event->mutex);
return PLT_WAIT_SUCCESS;
#endif #endif
} }

View File

@ -64,15 +64,12 @@ int PltCreateEvent(PLT_EVENT* event);
void PltCloseEvent(PLT_EVENT* event); void PltCloseEvent(PLT_EVENT* event);
void PltSetEvent(PLT_EVENT* event); void PltSetEvent(PLT_EVENT* event);
void PltClearEvent(PLT_EVENT* event); void PltClearEvent(PLT_EVENT* event);
int PltWaitForEvent(PLT_EVENT* event); void PltWaitForEvent(PLT_EVENT* event);
int PltCreateConditionVariable(PLT_COND* cond, PLT_MUTEX* mutex); int PltCreateConditionVariable(PLT_COND* cond, PLT_MUTEX* mutex);
void PltDeleteConditionVariable(PLT_COND* cond); void PltDeleteConditionVariable(PLT_COND* cond);
void PltSignalConditionVariable(PLT_COND* cond); void PltSignalConditionVariable(PLT_COND* cond);
void PltWaitForConditionVariable(PLT_COND* cond, PLT_MUTEX* mutex); void PltWaitForConditionVariable(PLT_COND* cond, PLT_MUTEX* mutex);
#define PLT_WAIT_SUCCESS 0
#define PLT_WAIT_INTERRUPTED 1
void PltSleepMs(int ms); void PltSleepMs(int ms);
void PltSleepMsInterruptible(PLT_THREAD* thread, int ms); void PltSleepMsInterruptible(PLT_THREAD* thread, int ms);