Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2006 - 2007 Pekka Riikonen
+ Copyright (C) 2006 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-/****h* silcutil/SILC Condition Variable Interface
+/****h* silcutil/Condition Variable Interface
*
* DESCRIPTION
*
* 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
#define SILCCOND_H
-/****s* silcutil/SilcCondAPI/SilcCond
+/****s* silcutil/SilcCond
*
* NAME
*
***/
typedef struct SilcCondStruct *SilcCond;
-/****s* silcutil/SilcCondAPI/silc_cond_alloc
+/****f* silcutil/silc_cond_alloc
*
* SYNOPSIS
*
* 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);
-/****s* silcutil/SilcCondAPI/silc_cond_free
+/****f* silcutil/silc_cond_free
*
* SYNOPSIS
*
***/
void silc_cond_free(SilcCond cond);
-/****s* silcutil/SilcCondAPI/silc_cond_wait
+/****f* silcutil/silc_cond_wait
*
* SYNOPSIS
*
***/
void silc_cond_wait(SilcCond cond, SilcMutex mutex);
-/****s* silcutil/SilcCondAPI/silc_cond_timedwait
+/****f* silcutil/silc_cond_timedwait
*
* SYNOPSIS
*
***/
SilcBool silc_cond_timedwait(SilcCond cond, SilcMutex mutex, int timeout);
-/****s* silcutil/SilcCondAPI/silc_cond_signal
+/****f* silcutil/silc_cond_signal
*
* SYNOPSIS
*
***/
void silc_cond_signal(SilcCond cond);
-/****s* silcutil/SilcCondAPI/silc_cond_broadcast
+/****f* silcutil/silc_cond_broadcast
*
* SYNOPSIS
*