summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-08-15 19:56:01 +0000
committerNick Mathewson <nickm@torproject.org>2007-08-15 19:56:01 +0000
commit181ba71a90359f67e90664be290af4d0ed57db8d (patch)
treed80ac2bbf3ea6a59a1a7c57ba1675215a8e83aac /src/common/compat.c
parentabad4dfc7aa0f98d3dc63470934f181aaec78807 (diff)
downloadtor-181ba71a90359f67e90664be290af4d0ed57db8d.tar.gz
tor-181ba71a90359f67e90664be290af4d0ed57db8d.zip
r14051@Kushana: nickm | 2007-08-15 15:55:36 -0400
Fix an XXXX020 and a few DOCDOCs. svn:r11127
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 0becc00be7..ebddce74b1 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1652,11 +1652,13 @@ struct tor_mutex_t {
};
#endif
-/* Condition stuff. DOCDOC */
+/* Conditions. */
#ifdef USE_PTHREADS
+/** Cross-platform condtion implementation. */
struct tor_cond_t {
pthread_cond_t cond;
};
+/** Return a newly allocated condition, with nobody waiting on it. */
tor_cond_t *
tor_cond_new(void)
{
@@ -1667,6 +1669,7 @@ tor_cond_new(void)
}
return cond;
}
+/** Release all resources held by <b>cond</b>. */
void
tor_conf_free(tor_cond_t *cond)
{
@@ -1677,21 +1680,27 @@ tor_conf_free(tor_cond_t *cond)
}
tor_free(cond);
}
+/** Wait until one of the tor_cond_signal functions is called on <b>cond</b>.
+ * All waiters on the condition must wait holding the same <b>mutex</b>.
+ * Returns 0 on success, negative on failure. */
int
tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex)
{
return pthread_cond_wait(&cond->cond, &mutex->mutex) ? -1 : 0;
}
+/** Wake up one of the waiters on <b>cond</b>. */
void
tor_cond_signal_one(tor_cond_t *cond)
{
pthread_cond_signal(&cond->cond);
}
+/** Wake up all of the waiters on <b>cond</b>. */
void
tor_cond_signal_all(tor_cond_t *cond)
{
pthread_cond_broadcast(&cond->cond);
}
+/** Set up common structures for use by threading. */
void
tor_threads_init(void)
{