[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


cma_cond_wait

Causes a thread to wait for a condition variable to be signaled or broadcasted.

Syntax

cma_cond_wait(
              condition,
              mutex);
 


Argument Data Type Access

condition opaque cma_t_cond read mutex opaque cma_t_mutex read


C Binding

#include 

void cma_cond_wait ( cma_t_cond *condition, cma_t_mutex *mutex);

Arguments

condition
Handle of the condition variable on which the thread waits.
mutex
Mutex associated with the condition variable specified in condition.

Description

This routine causes a thread to wait for a condition variable to be signaled or broadcasted. Each condition corresponds to one or more predicates upon the data. The calling thread waits for the data to reach a particular state (for a particular predicate to become true).

Call this routine after you have locked the mutex specified in mutex. The results of this routine are unpredictable if this routine is called without first locking the mutex.

This routine atomically releases the mutex and causes the calling thread to wait on the condition. If the wait is satisfied as a result of some thread calling cma_cond_signal or cma_cond_broadcast, the mutex is reacquired and the routine returns.

As a general rule, a thread that has changed the state of storage protected by the mutex in such a way that a predicate associated with a condition variable might now be true must call either cma_ cond_signal or cma_cond_broadcast for that condition variable. If neither call is made, any thread waiting on the condition variable continues to wait.

This routine is alertable. Alertable means that a pending alert is noticed during the wait on the condition variable. This helps ensure that all long waits can be canceled by alerting the thread.

If the cma_e_alerted exception is raised, the mutex is reacquired before the exception is raised.

This routine might (with low probability) return when the condition variable has not been signaled or broadcasted. When a spurious wakeup occurs, the mutex is reacquired before the routine returns. (To handle this type of situation, this routine should always be enclosed in a loop that tests for the desired shared data state.)

Exceptions

cma_e_alerted
cma_e_existence
cma_e_use_error



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]