Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Condition Variable Routines
[Brought To You By APR]


Typedefs

typedef apr_thread_cond_t switch_thread_cond_t

Functions

switch_status_t switch_thread_cond_create (switch_thread_cond_t **cond, switch_memory_pool_t *pool)
switch_status_t switch_thread_cond_wait (switch_thread_cond_t *cond, switch_mutex_t *mutex)
switch_status_t switch_thread_cond_timedwait (switch_thread_cond_t *cond, switch_mutex_t *mutex, switch_interval_time_t timeout)
switch_status_t switch_thread_cond_signal (switch_thread_cond_t *cond)
switch_status_t switch_thread_cond_broadcast (switch_thread_cond_t *cond)
switch_status_t switch_thread_cond_destroy (switch_thread_cond_t *cond)


Typedef Documentation

typedef struct apr_thread_cond_t switch_thread_cond_t
 

Opaque structure for thread condition variables


Function Documentation

switch_status_t switch_thread_cond_broadcast switch_thread_cond_t cond  ) 
 

Signals all threads blocking on the given condition variable. Each thread that was signaled is then scheduled to wake up and acquire the associated mutex. This will happen in a serialized manner.

Parameters:
cond the condition variable on which to produce the broadcast.
00292 {
00293         return apr_thread_cond_broadcast(cond);
00294 }

switch_status_t switch_thread_cond_create switch_thread_cond_t **  cond,
switch_memory_pool_t pool
 

Create and initialize a condition variable that can be used to signal and schedule threads in a single process.

Parameters:
cond the memory address where the newly created condition variable will be stored.
pool the pool from which to allocate the mutex.
00272 {
00273         return apr_thread_cond_create(cond, pool);
00274 }

switch_status_t switch_thread_cond_destroy switch_thread_cond_t cond  ) 
 

Destroy the condition variable and free the associated memory.

Parameters:
cond the condition variable to destroy.
00297 {
00298         return apr_thread_cond_destroy(cond);
00299 }

switch_status_t switch_thread_cond_signal switch_thread_cond_t cond  ) 
 

Signals a single thread, if one exists, that is blocking on the given condition variable. That thread is then scheduled to wake up and acquire the associated mutex. Although it is not required, if predictable scheduling is desired, that mutex must be locked while calling this function.

Parameters:
cond the condition variable on which to produce the signal.
00287 {
00288         return apr_thread_cond_signal(cond);
00289 }

switch_status_t switch_thread_cond_timedwait switch_thread_cond_t cond,
switch_mutex_t mutex,
switch_interval_time_t  timeout
 

Put the active calling thread to sleep until signaled to wake up or the timeout is reached. Each condition variable must be associated with a mutex, and that mutex must be locked before calling this function, or the behavior will be undefined. As the calling thread is put to sleep, the given mutex will be simultaneously released; and as this thread wakes up the lock is again simultaneously acquired.

Parameters:
cond the condition variable on which to block.
mutex the mutex that must be locked upon entering this function, is released while the thread is asleep, and is again acquired before returning from this function.
timeout The amount of time in microseconds to wait. This is a maximum, not a minimum. If the condition is signaled, we will wake up before this time, otherwise the error APR_TIMEUP is returned.
00282 {
00283         return apr_thread_cond_timedwait(cond, mutex, timeout);
00284 }

switch_status_t switch_thread_cond_wait switch_thread_cond_t cond,
switch_mutex_t mutex
 

Put the active calling thread to sleep until signaled to wake up. Each condition variable must be associated with a mutex, and that mutex must be locked before calling this function, or the behavior will be undefined. As the calling thread is put to sleep, the given mutex will be simultaneously released; and as this thread wakes up the lock is again simultaneously acquired.

Parameters:
cond the condition variable on which to block.
mutex the mutex that must be locked upon entering this function, is released while the thread is asleep, and is again acquired before returning from this function.
00277 {
00278         return apr_thread_cond_wait(cond, mutex);
00279 }


Generated on Fri Oct 10 11:24:22 2008 for FreeSWITCH by  doxygen 1.3.9.1