Implement switch_queue_pop_timeout() and refactor sofia_profile_worker_thread_run() to use it so it doesn't wake up too often

This commit is contained in:
Mathieu Rene
2010-11-18 21:00:21 -05:00
parent 42a4a3dedf
commit de417e99f0
6 changed files with 148 additions and 46 deletions
+16
View File
@@ -592,6 +592,22 @@ SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t ** queue, uns
*/
SWITCH_DECLARE(switch_status_t) switch_queue_pop(switch_queue_t *queue, void **data);
/**
* pop/get an object from the queue, blocking if the queue is already empty
*
* @param queue the queue
* @param data the data
* @param 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.
* @returns APR_TIMEUP the request timed out
* @returns APR_EINTR the blocking was interrupted (try again)
* @returns APR_EOF if the queue has been terminated
* @returns APR_SUCCESS on a successfull pop
*/
SWITCH_DECLARE(switch_status_t) switch_queue_pop_timeout(switch_queue_t *queue, void **data, switch_interval_time_t timeout);
/**
* push/add a object to the queue, blocking if the queue is already full
*