X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilccond.h;h=59918a48ef3aa6b4d14bf7204cc5476bb6b11b1f;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hp=1fe8bb21001512b34086243c48ed8b89ca64c18b;hpb=8fd8212bcd16f2b53fbedff2a9b9a4e8c15b9695;p=silc.git diff --git a/lib/silcutil/silccond.h b/lib/silcutil/silccond.h index 1fe8bb21..59918a48 100644 --- a/lib/silcutil/silccond.h +++ b/lib/silcutil/silccond.h @@ -25,6 +25,25 @@ * Condition variables enable threads to suspend execution and yield * the processors until some predicate on some shared data is satisfied. * + * EXAMPLE + * + * Thread 1: + * + * // Wait for signal + * silc_mutex_lock(lock); + * while (c->a == NULL) + * silc_cond_wait(cond, lock); + * ... + * silc_mutex_unlock(lock); + * + * Thread 2: + * + * // Signal + * silc_mutex_lock(lock); + * c->a = context; + * silc_cond_signal(cond); + * silc_mutex_unlock(lock); + * ***/ #ifndef SILCCOND_H @@ -56,7 +75,8 @@ typedef struct SilcCondStruct *SilcCond; * Allocates SILC Condition variable context. The condition must * be allocated before it can be used. It is freed by the * silc_cond_free function. This returns TRUE and allocated - * condition in to the `cond' pointer and FALSE on error. + * condition in to the `cond' pointer and FALSE if system is out of + * memory. * ***/ SilcBool silc_cond_alloc(SilcCond *cond);