diff options
author | Chris Robinson <[email protected]> | 2018-11-10 22:53:03 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-10 22:53:03 -0800 |
commit | 5bc2918e16c0ec5b43837ed0a12bfa1f7187103a (patch) | |
tree | ad2ecc08749c2d6455f826e5c5e4988e41d1b52e /common/threads.c | |
parent | f3ce7bc7dcf20275d93974755c42486d812d771f (diff) |
Remove the unused condition variable APIs
Diffstat (limited to 'common/threads.c')
-rw-r--r-- | common/threads.c | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/common/threads.c b/common/threads.c index de9fc452..16604267 100644 --- a/common/threads.c +++ b/common/threads.c @@ -192,125 +192,6 @@ void almtx_destroy(almtx_t *mtx) DeleteCriticalSection(mtx); } -#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 -int alcnd_init(alcnd_t *cond) -{ - InitializeConditionVariable(cond); - return althrd_success; -} - -int alcnd_signal(alcnd_t *cond) -{ - WakeConditionVariable(cond); - return althrd_success; -} - -int alcnd_broadcast(alcnd_t *cond) -{ - WakeAllConditionVariable(cond); - return althrd_success; -} - -int alcnd_wait(alcnd_t *cond, almtx_t *mtx) -{ - if(SleepConditionVariableCS(cond, mtx, INFINITE) != 0) - return althrd_success; - return althrd_error; -} - -void alcnd_destroy(alcnd_t* UNUSED(cond)) -{ - /* Nothing to delete? */ -} - -#else - -/* WARNING: This is a rather poor implementation of condition variables, with - * known problems. However, it's simple, efficient, and good enough for now to - * not require Vista. Based on "Strategies for Implementing POSIX Condition - * Variables" by Douglas C. Schmidt and Irfan Pyarali: - * http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - */ -/* A better solution may be using Wine's implementation. It requires internals - * (NtCreateKeyedEvent, NtReleaseKeyedEvent, and NtWaitForKeyedEvent) from - * ntdll, and implemention of exchange and compare-exchange for RefCounts. - */ - -typedef struct { - RefCount wait_count; - - HANDLE events[2]; -} _int_alcnd_t; -enum { - SIGNAL = 0, - BROADCAST = 1 -}; - -int alcnd_init(alcnd_t *cond) -{ - _int_alcnd_t *icond = calloc(1, sizeof(*icond)); - if(!icond) return althrd_nomem; - - InitRef(&icond->wait_count, 0); - - icond->events[SIGNAL] = CreateEventW(NULL, FALSE, FALSE, NULL); - icond->events[BROADCAST] = CreateEventW(NULL, TRUE, FALSE, NULL); - if(!icond->events[SIGNAL] || !icond->events[BROADCAST]) - { - if(icond->events[SIGNAL]) - CloseHandle(icond->events[SIGNAL]); - if(icond->events[BROADCAST]) - CloseHandle(icond->events[BROADCAST]); - free(icond); - return althrd_error; - } - - cond->Ptr = icond; - return althrd_success; -} - -int alcnd_signal(alcnd_t *cond) -{ - _int_alcnd_t *icond = cond->Ptr; - if(ReadRef(&icond->wait_count) > 0) - SetEvent(icond->events[SIGNAL]); - return althrd_success; -} - -int alcnd_broadcast(alcnd_t *cond) -{ - _int_alcnd_t *icond = cond->Ptr; - if(ReadRef(&icond->wait_count) > 0) - SetEvent(icond->events[BROADCAST]); - return althrd_success; -} - -int alcnd_wait(alcnd_t *cond, almtx_t *mtx) -{ - _int_alcnd_t *icond = cond->Ptr; - int res; - - IncrementRef(&icond->wait_count); - LeaveCriticalSection(mtx); - - res = WaitForMultipleObjects(2, icond->events, FALSE, INFINITE); - - if(DecrementRef(&icond->wait_count) == 0 && res == WAIT_OBJECT_0+BROADCAST) - ResetEvent(icond->events[BROADCAST]); - EnterCriticalSection(mtx); - - return althrd_success; -} - -void alcnd_destroy(alcnd_t *cond) -{ - _int_alcnd_t *icond = cond->Ptr; - CloseHandle(icond->events[SIGNAL]); - CloseHandle(icond->events[BROADCAST]); - free(icond); -} -#endif /* defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 */ - int alsem_init(alsem_t *sem, unsigned int initial) { @@ -560,39 +441,6 @@ void almtx_destroy(almtx_t *mtx) pthread_mutex_destroy(mtx); } -int alcnd_init(alcnd_t *cond) -{ - if(pthread_cond_init(cond, NULL) == 0) - return althrd_success; - return althrd_error; -} - -int alcnd_signal(alcnd_t *cond) -{ - if(pthread_cond_signal(cond) == 0) - return althrd_success; - return althrd_error; -} - -int alcnd_broadcast(alcnd_t *cond) -{ - if(pthread_cond_broadcast(cond) == 0) - return althrd_success; - return althrd_error; -} - -int alcnd_wait(alcnd_t *cond, almtx_t *mtx) -{ - if(pthread_cond_wait(cond, mtx) == 0) - return althrd_success; - return althrd_error; -} - -void alcnd_destroy(alcnd_t *cond) -{ - pthread_cond_destroy(cond); -} - #ifdef __APPLE__ |