pthread_cond_destroy() — Destroy the condition variable object
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.4a |
both | POSIX(ON) |
Format
#define _OPEN_THREADS
#include <pthread.h>
int pthread_cond_destroy(pthread_cond_t *cond);
SUSV3:
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_cond_destroy(pthread_cond_t *cond);
General description
Destroys the condition variable object specified by cond.
A condition variable object identifies a condition variable. Condition variables are used in conjunction with mutexes to protect shared resources.
Returned value
If successful, pthread_cond_destroy() returns 0.
If unsuccessful, pthread_cond_destroy() returns
-1 and sets errno to one of the following values:
- Error Code
- Description
- EBUSY
- An attempt was made to destroy the object referenced by cond while it is referenced by another thread.
- EINVAL
- The value specified by cond is not valid.
Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_cond_destroy() returns an error number to indicate the error.
Example
CELEBP18
/* CELEBP18 */
#define _OPEN_THREADS
#include <pthread.h>
#include <stdio.h>
main() {
pthread_cond_t cond;
if (pthread_cond_init(&cond, NULL) != 0) {
perror("pthread_cond_init() error");
exit(1);
}
if (pthread_cond_destroy(&cond) != 0) {
perror("pthread_cond_destroy() error");
exit(2);
}
}