# pthread_barrier_destroy

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           pthread_barrier_destroy, pthread_barrier_init — destroy and
           initialize a barrier object
    


## SYNOPSIS



           #include <pthread.h>
    
           int pthread_barrier_destroy(pthread_barrier_t *_barrier_);
           int pthread_barrier_init(pthread_barrier_t *restrict _barrier_ ,
               const pthread_barrierattr_t *restrict _attr_ , unsigned _count_);
    


## DESCRIPTION



           The _pthread_barrier_destroy_() function shall destroy the barrier
           referenced by _barrier_ and release any resources used by the
           barrier. The effect of subsequent use of the barrier is undefined
           until the barrier is reinitialized by another call to
           _pthread_barrier_init_().  An implementation may use this function
           to set _barrier_ to an invalid value. The results are undefined if
           _pthread_barrier_destroy_() is called when any thread is blocked on
           the barrier, or if this function is called with an uninitialized
           barrier.
    
           The _pthread_barrier_init_() function shall allocate any resources
           required to use the barrier referenced by _barrier_ and shall
           initialize the barrier with attributes referenced by _attr_.  If
           _attr_ is NULL, the default barrier attributes shall be used; the
           effect is the same as passing the address of a default barrier
           attributes object. The results are undefined if
           _pthread_barrier_init_() is called when any thread is blocked on the
           barrier (that is, has not returned from the _pthread_barrier_wait_()
           call). The results are undefined if a barrier is used without
           first being initialized. The results are undefined if
           _pthread_barrier_init_() is called specifying an already initialized
           barrier.
    
           The _count_ argument specifies the number of threads that must call
           _pthread_barrier_wait_() before any of them successfully return from
           the call. The value specified by _count_ must be greater than zero.
    
           If the _pthread_barrier_init_() function fails, the barrier shall
           not be initialized and the contents of _barrier_ are undefined.
    
           See _Section 2.9.9_ , _Synchronization Object Copies and Alternative_
           _Mappings_ for further requirements.
    


## RETURN VALUE



           Upon successful completion, these functions shall return zero;
           otherwise, an error number shall be returned to indicate the
           error.
    


## ERRORS



           The _pthread_barrier_init_() function shall fail if:
    
           **EAGAIN** The system lacks the necessary resources to initialize
                  another barrier.
    
           **EINVAL** The value specified by _count_ is equal to zero.
    
           **ENOMEM** Insufficient memory exists to initialize the barrier.
    
           These functions shall not return an error code of **[EINTR]**.
    
           _The following sections are informative._
    


## EXAMPLES



           None.
    


## APPLICATION USAGE



           None.
    


## RATIONALE



           If an implementation detects that the value specified by the
           _barrier_ argument to _pthread_barrier_destroy_() does not refer to an
           initialized barrier object, it is recommended that the function
           should fail and report an **[EINVAL]** error.
    
           If an implementation detects that the value specified by the _attr_
           argument to _pthread_barrier_init_() does not refer to an
           initialized barrier attributes object, it is recommended that the
           function should fail and report an **[EINVAL]** error.
    
           If an implementation detects that the value specified by the
           _barrier_ argument to _pthread_barrier_destroy_() or
           _pthread_barrier_init_() refers to a barrier that is in use (for
           example, in a _pthread_barrier_wait_() call) by another thread, or
           detects that the value specified by the _barrier_ argument to
           _pthread_barrier_init_() refers to an already initialized barrier
           object, it is recommended that the function should fail and report
           an **[EBUSY]** error.
    


## FUTURE DIRECTIONS



           None.
    


* * *