NAME
cnd_destroy
cnd_init — destroy and
initialize condition variables
SYNOPSIS
#include
<threads.h>
void cnd_destroy(cnd_t *cond); int cnd_init(cnd_t *cond);
DESCRIPTION
[CX] The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2024 defers to the ISO C standard.
The cnd_destroy () function shall release
all resources used by the condition variable pointed to by
cond. It shall be safe to destroy an initialized condition
variable upon which no threads are currently blocked. Attempting to destroy
a condition variable upon which other threads are currently blocked results
in undefined behavior. A destroyed condition variable object can be
reinitialized using cnd_init (); the results of
otherwise referencing the object after it has been destroyed are undefined.
The behavior is undefined if the value specified by the
cond argument to cnd_destroy ()
does not refer to an initialized condition variable.
The cnd_init () function shall initialize
a condition variable. If it succeeds it shall set the variable pointed to by
cond to a value that uniquely identifies the newly
initialized condition variable. Attempting to initialize an already
initialized condition variable results in undefined behavior. A thread that
calls cnd_wait(3) on a newly initialized condition
variable shall block.
[CX] See V2_chap02(3) for further requirements.
These functions shall not be affected if the calling thread executes a signal handler during the call.
RETURN VALUE
The cnd_destroy () function shall not
return a value.
The cnd_init () function shall return
thrd_success on success, or
thrd_nomem if no memory could be allocated for the
newly created condition variable, or thrd_error if
the request could not be honored.
ERRORS
See RETURN VALUE.
EXAMPLES
None.
APPLICATION USAGE
None.
RATIONALE
These functions are not affected by signal handlers for the reasons stated in XRAT B.2.3 Error Numbers.
FUTURE DIRECTIONS
None.
SEE ALSO
cnd_broadcast(3), cnd_timedwait(3)
XBD <threads.h>
CHANGE HISTORY
First released in Issue 8. Included for alignment with the ISO/IEC 9899:2018 standard.