ARGOBOTS
1.1
|
This group is for Condition Variable. More...
Data Structures | |
struct | ABT_cond_memory |
A struct that can be converted to ABT_cond. More... | |
Macros | |
#define | ABT_COND_INITIALIZER { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } |
Initialize ABT_cond_memory . More... | |
#define | ABT_COND_MEMORY_GET_HANDLE(p_cond_memory) ((ABT_cond)p_cond_memory) |
Obtain ABT_cond from ABT_cond_memory . More... | |
Typedefs | |
typedef struct ABT_cond_opaque * | ABT_cond |
Condition variable handle type. More... | |
Functions | |
int | ABT_cond_create (ABT_cond *newcond) |
Create a new condition variable. More... | |
int | ABT_cond_free (ABT_cond *cond) |
Free a condition variable. More... | |
int | ABT_cond_wait (ABT_cond cond, ABT_mutex mutex) |
Wait on a condition variable. More... | |
int | ABT_cond_timedwait (ABT_cond cond, ABT_mutex mutex, const struct timespec *abstime) |
Wait on a condition variable with a timeout limit. More... | |
int | ABT_cond_signal (ABT_cond cond) |
Signal a condition. More... | |
int | ABT_cond_broadcast (ABT_cond cond) |
Broadcast a condition. More... | |
This group is for Condition Variable.
#define ABT_COND_INITIALIZER { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } |
Initialize ABT_cond_memory
.
ABT_COND_INITIALIZER
statically initializes ABT_cond_memory
.
The following example shows how to use ABT_COND_INITIALIZER
.
ABT_cond_memory
that is in use may not be initialized again.
#define ABT_COND_MEMORY_GET_HANDLE | ( | p_cond_memory | ) | ((ABT_cond)p_cond_memory) |
Obtain ABT_cond
from ABT_cond_memory
.
ABT_COND_MEMORY_GET_HANDLE()
takes the pointer p_cond_memory
, which points to ABT_cond_memory
, and returns ABT_cond
that internally uses p_cond_memory
to store the data. If the memory pointed to by p_cond_memory
is not properly initialized, it returns a corrupted condition variable.
ABT_cond
obtained by ABT_COND_MEMORY_GET_HANDLE()
may not be freed by ABT_cond_free()
. The lifetime of ABT_cond
obtained by ABT_COND_MEMORY_GET_HANDLE()
is the same as that of ABT_cond_memory
.
typedef struct ABT_cond_opaque* ABT_cond |
int ABT_cond_broadcast | ( | ABT_cond | cond | ) |
Broadcast a condition.
ABT_cond_broadcast()
signals all waiters that are blocked on the condition variable cond
. The caller does not need to be holding a mutex associated with cond
. This routine has no effect if no waiter is currently blocked on cond
.
ABT_SUCCESS
is returned if this routine succeeds.ABT_ERR_INV_COND
is returned if cond
is ABT_COND_NULL
.[in] | cond | condition variable handle |
int ABT_cond_create | ( | ABT_cond * | newcond | ) |
Create a new condition variable.
ABT_cond_create()
creates a new condition variable and returns its handle through newcond
.
newcond
must be freed by ABT_cond_free()
after its use.
newcond
is set to ABT_COND_NULL
if an error occurs.newcond
is not updated if an error occurs. newcond
when an error occurs. ABT_SUCCESS
is returned if this routine succeeds.ABT_ERR_MEM
is returned if memory allocation fails.ABT_ERR_SYS
is returned if an error related to system calls and standard libraries occurs.newcond
is NULL
, the results are undefined.[out] | newcond | condition variable handle |
int ABT_cond_free | ( | ABT_cond * | cond | ) |
Free a condition variable.
ABT_cond_free()
deallocates the resource used for the condition variable cond
and sets cond
to ABT_COND_NULL
.
ABT_ERR_COND
is returned if this routine finds a waiter on cond
.cond
. cond
. From Argobots 2.0, it becomes the user's responsibility to ensure that no waiter is blocked on cond
. ABT_SUCCESS
is returned if this routine succeeds.ABT_ERR_INV_COND
is returned if cond
points to ABT_COND_NULL
.ABT_ERR_COND
is returned if there is a waiter blocked on cond
.cond
is NULL
, the results are undefined.cond
is accessed after calling this routine, the results are undefined.cond
, the results are undefined.[in,out] | cond | condition variable handle |
int ABT_cond_signal | ( | ABT_cond | cond | ) |
Signal a condition.
ABT_cond_signal()
signals another waiter that is blocked on the condition variable cond
. Only one waiter is signaled and woken up. The caller does not need to be holding a mutex associated with cond
. This routine has no effect if no waiter is currently blocked on cond
.
ABT_SUCCESS
is returned if this routine succeeds.ABT_ERR_INV_COND
is returned if cond
is ABT_COND_NULL
.[in] | cond | condition variable handle |
Wait on a condition variable with a timeout limit.
The caller of ABT_cond_timedwait()
waits on the condition variable cond
until either it is signaled or the absolute time specified by abstime
passes. The user must call this routine while the mutex mutex
is locked. mutex
will be automatically released while waiting. When the caller is woken up, mutex
will be automatically locked by the caller. The user is then responsible for unlocking mutex
. If the system time exceeds abstime
before cond
is signaled, ABT_ERR_COND_TIMEDOUT
is returned.
clock_gettime()
can be used to obtain the current system time. This routine associates mutex
with cond
until this routine returns, so the user may not use more than one mutex for the same cond
.
This routine returns with mutex
locked even if an error occurs.
If mutex
is a recursive mutex, mutex
must be locked only once by the caller.
ABT_SUCCESS
is returned if this caller is woken up by a signal.ABT_ERR_COND_TIMEDOUT
is returned if the system time exceeds abstime
before cond
is signaled.ABT_ERR_INV_COND
is returned if cond
is ABT_COND_NULL
.ABT_ERR_INV_MUTEX
is returned if mutex
is ABT_MUTEX_NULL
.abstime
is NULL
, the results are undefined.mutex
is not locked, the results are undefined.mutex
is a recursive mutex and the caller does not have ownership of mutex
, the results are undefined.mutex
is a recursive mutex and has been locked more than once, the results are undefined.cond
has been associated with a mutex other than mutex
, the results are undefined.[in] | cond | condition variable handle |
[in] | mutex | mutex handle |
[in] | abstime | absolute time for timeout |
Wait on a condition variable.
The caller of ABT_cond_wait()
waits on the condition variable cond
until it is signaled. The user must call this routine while the mutex mutex
is locked. mutex
will be automatically released while waiting. When the caller is woken up, mutex
will be automatically locked by the caller. The user is then responsible for unlocking mutex
.
This routine associates mutex
with cond
until this routine returns, so the user may not use more than one mutex for the same cond
.
This routine returns with mutex
locked even if an error occurs.
If mutex
is a recursive mutex, mutex
must be locked only once by the caller.
ABT_ERR_COND
is returned.ABT_SUCCESS
is returned if this routine succeeds.ABT_ERR_INV_COND
is returned if cond
is ABT_COND_NULL
.ABT_ERR_INV_MUTEX
is returned if mutex
is ABT_MUTEX_NULL
.ABT_ERR_COND
is returned if the caller is a tasklet.mutex
is not locked, the results are undefined.mutex
is a recursive mutex and the caller does not have ownership of mutex
, the results are undefined.mutex
is a recursive mutex and has been locked more than once, the results are undefined.cond
has been associated with a mutex other than mutex
, the results are undefined.[in] | cond | condition variable handle |
[in] | mutex | mutex handle |