Name

pthread_cond_destroy
- destroy a condition variable

Library

libc_r.lib libpthread.lib libthr.lib

Synopsis

  #include <pthread.h>
  int pthread_cond_destroy (pthread_cond_t *cond);

Return values

If successful, the pthread_cond_destroy function will return zero, otherwise an error number will be returned to indicate the error.

Detailed description

The pthread_cond_destroy function frees the resources allocated by the condition variable cond.

Examples

int rc;
struct testdata
{
 pthread_mutex_t mutex;
 pthread_cond_t  cond;
};
static struct testdata td;
int function1()
{
 /* Initialize a condition variable object */
 if (pthread_cond_init(&td.cond, NULL) != 0) {
  fprintf(stderr,"Fail to initialize cond\n");
  return -1;
 }
 /* ... Use it for wait, signal, broadcast */
 /* Destroy the condition variable object */
 if((rc=pthread_cond_destroy(&td.cond)) != 0)
 {
   fprintf(stderr,"Error at pthread_cond_destroy(), rc=%d\n",rc);
   return -1;
 }
}

         

Errors

The pthread_cond_destroy function will fail if:
[EINVAL]
  The value specified by cond is invalid.
[EAGAIN]
  The variable cond is locked by another thread.

See also

pthread_cond_broadcast, pthread_cond_init, pthread_cond_signal, pthread_cond_timedwait, pthread_cond_wait

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top