aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-27 04:59:43 -0700
committerChris Robinson <[email protected]>2014-05-27 05:22:53 -0700
commitf0b65aa6b7356bc926f0b5217676ec8575ef5d00 (patch)
treef6166ef090930479b462dc7b2e917f3ab90c05cf /include
parent2d2bc25fd0e67f5611ce1bf4113108b3acf2c416 (diff)
Implement condition variables for Windows
Diffstat (limited to 'include')
-rw-r--r--include/threads.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/include/threads.h b/include/threads.h
index 8b633f33..4a974b53 100644
--- a/include/threads.h
+++ b/include/threads.h
@@ -39,6 +39,11 @@ struct timespec {
typedef DWORD althrd_t;
typedef CRITICAL_SECTION almtx_t;
+#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
+typedef CONDITION_VARIABLE alcnd_t;
+#else
+typedef struct { void *Ptr; } alcnd_t;
+#endif
typedef DWORD altss_t;
typedef LONG alonce_flag;
@@ -120,16 +125,6 @@ typedef pthread_once_t alonce_flag;
#define AL_ONCE_FLAG_INIT PTHREAD_ONCE_INIT
-/* NOTE: Condition variables are POSIX-only at the moment, as Windows requires
- * Vista or newer for them (without slow, hacky work-arounds). */
-int alcnd_init(alcnd_t *cond);
-int alcnd_signal(alcnd_t *cond);
-int alcnd_broadcast(alcnd_t *cond);
-int alcnd_wait(alcnd_t *cond, almtx_t *mtx);
-int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point);
-void alcnd_destroy(alcnd_t *cond);
-
-
inline althrd_t althrd_current(void)
{
return pthread_self();
@@ -218,6 +213,13 @@ int almtx_init(almtx_t *mtx, int type);
void almtx_destroy(almtx_t *mtx);
int almtx_timedlock(almtx_t *mtx, const struct timespec *ts);
+int alcnd_init(alcnd_t *cond);
+int alcnd_signal(alcnd_t *cond);
+int alcnd_broadcast(alcnd_t *cond);
+int alcnd_wait(alcnd_t *cond, almtx_t *mtx);
+int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point);
+void alcnd_destroy(alcnd_t *cond);
+
int altss_create(altss_t *tss_id, altss_dtor_t callback);
void altss_delete(altss_t tss_id);