PTHREAD_BARRIER_INIT(3) | Library Functions Manual | PTHREAD_BARRIER_INIT(3) |
pthread_barrier_init
,
pthread_barrier_destroy
—
initialize and destroy a barrier object
#include
<pthread.h>
int
pthread_barrier_init
(pthread_barrier_t
*barrier,
pthread_barrierattr_t
*attr, unsigned int
count);
int
pthread_barrier_destroy
(pthread_barrier_t
*barrier);
The
pthread_barrier_init
()
function creates a new barrier object, with attributes specified with
attr and with a threshold specified with
count. If attr is
NULL
the default attributes are used. The
count argument is later used by the
pthread_barrier_wait
()
function to check if the required number of threads reached the barrier.
The
pthread_barrier_destroy
()
function frees the resources allocated for
barrier.
If successful, pthread_barrier_init
() and
pthread_barrier_destroy
() return zero; otherwise an
error number is returned to indicate the error.
pthread_barrier_init
() will fail if:
EINVAL
]ENOMEM
]ENOTSUP
]pthread_barrier_destroy
() will fail
if:
pthread_barrier_wait(3), pthread_barrierattr_getpshared(3), pthread_barrierattr_init(3)
pthread_barrier_init
() and
pthread_barrier_destroy
() conform to
IEEE Std 1003.1-2008 (“POSIX.1”).
Currently only private barriers are supported and the pshared
attribute is always set that way. Any attempts to change that value will
trigger ENOTSUP
.
April 6, 2020 | OpenBSD-current |