aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat_threads.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-09-22 22:08:41 -0400
committerNick Mathewson <nickm@torproject.org>2015-01-14 10:47:39 -0500
commite865248156a8512d756be003118de446d29611d1 (patch)
treea19cf3d0fe7bd1bb700309f138b2480b6ed596af /src/common/compat_threads.h
parentc2f0d52b7fb937f3f66ef8b2b74b0fdf239b0e9b (diff)
downloadtor-e865248156a8512d756be003118de446d29611d1.tar.gz
tor-e865248156a8512d756be003118de446d29611d1.zip
Add a timeout to tor_cond_wait; add tor_cond impl from libevent
The windows code may need some tweaks for it to compile; I've not tested it yet.
Diffstat (limited to 'src/common/compat_threads.h')
-rw-r--r--src/common/compat_threads.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/common/compat_threads.h b/src/common/compat_threads.h
index f43e74ab8f..bbd782fd45 100644
--- a/src/common/compat_threads.h
+++ b/src/common/compat_threads.h
@@ -57,10 +57,25 @@ void tor_threads_init(void);
void set_main_thread(void);
int in_main_thread(void);
-typedef struct tor_cond_t tor_cond_t;
+typedef struct tor_cond_t {
+#ifdef USE_PTHREADS
+ pthread_cond_t cond;
+#elif defined(USE_WIN32_THREADS)
+ HANDLE event;
+
+ CRITICAL_SECTION lock;
+ int n_waiting;
+ int n_to_wake;
+ int generation;
+#else
+#error no known condition implementation.
+#endif
+} tor_cond_t;
+
tor_cond_t *tor_cond_new(void);
void tor_cond_free(tor_cond_t *cond);
-int tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex);
+int tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex,
+ const struct timeval *tv);
void tor_cond_signal_one(tor_cond_t *cond);
void tor_cond_signal_all(tor_cond_t *cond);