Collaboration diagram for Condition Variable Routines:
| typedef struct apr_thread_cond_t switch_thread_cond_t |
Opaque structure for thread condition variables
Definition at line 512 of file switch_apr.h.
| 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.
| cond | the condition variable on which to produce the broadcast. |
Definition at line 393 of file switch_apr.c.
Referenced by SWITCH_MODULE_RUNTIME_FUNCTION().
00394 { 00395 return apr_thread_cond_broadcast(cond); 00396 }
| 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.
| cond | the memory address where the newly created condition variable will be stored. | |
| pool | the pool from which to allocate the mutex. |
Definition at line 367 of file switch_apr.c.
Referenced by speech_thread(), switch_core_session_request_uuid(), switch_core_sqldb_start(), SWITCH_MODULE_RUNTIME_FUNCTION(), switch_system_thread(), and timer_init().
| switch_status_t switch_thread_cond_destroy | ( | switch_thread_cond_t * | cond | ) |
Destroy the condition variable and free the associated memory.
| cond | the condition variable to destroy. |
Definition at line 398 of file switch_apr.c.
00399 { 00400 return apr_thread_cond_destroy(cond); 00401 }
| 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.
| cond | the condition variable on which to produce the signal. |
Definition at line 388 of file switch_apr.c.
Referenced by speech_callback(), switch_core_session_wake_session_thread(), system_thread(), and wake_thread().
00389 { 00390 return apr_thread_cond_signal(cond); 00391 }
| 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.
| 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. |
Definition at line 377 of file switch_apr.c.
References SWITCH_STATUS_TIMEOUT.
00378 { 00379 apr_status_t st = apr_thread_cond_timedwait(cond, mutex, timeout); 00380 00381 if (st == APR_TIMEUP) { 00382 st = SWITCH_STATUS_TIMEOUT; 00383 } 00384 00385 return st; 00386 }
| 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.
| 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. |
Definition at line 372 of file switch_apr.c.
Referenced by speech_thread(), switch_cond_next(), switch_cond_yield(), switch_core_session_run(), switch_core_sql_thread(), switch_system_thread(), and timer_next().
1.4.7