@node Condition variables
@subsection Condition variables

Condition variables are used to wait for a particular condition becoming
true (e.g new client connects to the server).

@node Condition variables dictionary
@subsection Condition variables dictionary


@cppdef mp_make_condition_variable
@lspdef mp:make-condition-variable

@deftypefun cl_object mp_make_condition_variable ()
@end deftypefun

@defun mp:make-condition-variable
Creates a condition variable.
@end defun


@cppdef mp_condition_variable_wait
@lspdef mp:condition-variable-wait

@deftypefun cl_object mp_condition_variable_wait (cl_object cv, cl_object lock)
@end deftypefun

@defun mp:condition-variable-wait cv lock
Release @var{lock} and suspend thread until condition
@coderef{mp:condition-variable-signal} is called on @var{cv}. When thread
resumes re-aquire @var{lock}.
@end defun


@cppdef mp_condition_variable_timedwait
@lspdef mp:condition-variable-timedwait

@deftypefun cl_object mp_condition_variable_timedwait (cl_object cv, cl_object lock, cl_object seconds)
@end deftypefun

@defun mp:condition-variable-timedwait cv lock seconds
@coderef{mp:condition-variable-wait} which timeouts after @var{seconds}
seconds.
@end defun


@cppdef mp_condition_variable_signal
@lspdef mp:condition-variable-signal

@deftypefun cl_object mp_condition_variable_signal (cl_object cv)
@end deftypefun

@defun mp:condition-variable-signal cv
Signal @var{cv} (wakes up only one waiter). After signal, signaling
thread keeps lock, waking thread goes on the queue waiting for the lock.

See @coderef{mp:condition-variable-wait}.
@end defun


@cppdef mp_condition_variable-broadcast
@lspdef mp:condition-variable-broadcast

@deftypefun cl_object mp_condition_variable_broadcast (cl_object cv)
@end deftypefun

@defun mp:condition-variable-broadcast cv
Signal @var{cv} (wakes up all waiters).

See @coderef{mp:condition-variable-wait}.  
@end defun
