pthread_cond_destroy()--Destroy Condition Variable


  Syntax:
 #include <pthread.h>
 int pthread_cond_destroy(pthread_cond_t *cond);   
  Service Program Name: QP0WPTHR

  Default Public Authority: *USE

  Threadsafe: Yes

  Signal Safe: Yes

The pthread_cond_destroy() function destroys the condition variable specified by cond. If threads are currently blocked on the condition variable, the pthread_cond_destroy() fails with the EBUSY error.


Authorities and Locks

None.


Parameters

cond
(Input) Address of the condition variable to destroy

Return Value

0
pthread_cond_destroy() was successful.
value
pthread_cond_destroy() was not successful. value is set to indicate the error condition.

Error Conditions

If pthread_cond_destroy() was not successful, the error condition returned usually indicates one of the following errors. Under some conditions, the value returned could indicate an error other than those listed here.

[EINVAL]

The value specified for the argument is not correct. 

[EBUSY]

The condition variable was in use.


Related Information


Example

See Code disclaimer information for information pertaining to code examples.

#include <pthread.h>
#include <stdio.h>
#include "check.h"

pthread_cond_t              cond;

int main(int argc, char **argv)
{
  int                   rc=0;
  pthread_mutexattr_t   attr;

  printf("Entering testcase\n");

  printf("Create the condition using the condition attributes object\n");
  rc = pthread_cond_init(&cond, NULL);
  checkResults("pthread_cond_init()\n", rc);

  printf("- At this point, the condition with its default attributes\n");
  printf("- Can be used from any threads that want to use it\n");

  printf("Destroy condition\n");
  rc = pthread_cond_destroy(&cond);
  checkResults("pthread_cond_destroy()\n", rc);
 
  printf("Main completed\n");
  return 0;
}

Output:

Entering testcase
Create the condition using the condition attributes object
- At this point, the condition with its default attributes
- Can be used from any threads that want to use it
Destroy condition
Main completed

API introduced: V4R3
Top | Pthread APIs | APIs by category