19 #include <fspr_thread_mutex.h> 20 #include <fspr_thread_cond.h> 46 fprintf(stderr,
"%ld\t#%d in %d out %d\t%s\n",
47 apr_os_thread_current(),
60 #define apr_queue_full(queue) ((queue)->nelts == (queue)->bounds) 66 #define apr_queue_empty(queue) ((queue)->nelts == 0) 78 fspr_thread_cond_destroy(queue->
not_empty);
79 fspr_thread_cond_destroy(queue->
not_full);
97 APR_THREAD_MUTEX_UNNESTED,
99 if (rv != APR_SUCCESS) {
103 rv = fspr_thread_cond_create(&queue->
not_empty, a);
104 if (rv != APR_SUCCESS) {
108 rv = fspr_thread_cond_create(&queue->
not_full, a);
109 if (rv != APR_SUCCESS) {
114 queue->
data = fspr_palloc(a, queue_capacity *
sizeof(
void*));
115 if (!queue->
data)
return APR_ENOMEM;
116 memset(queue->
data, 0, queue_capacity *
sizeof(
void*));
117 queue->
bounds = queue_capacity;
125 fspr_pool_cleanup_register(a, queue,
queue_destroy, fspr_pool_cleanup_null);
144 if (rv != APR_SUCCESS) {
153 if (rv != APR_SUCCESS) {
160 Q_DBG(
"queue full (intr)", queue);
162 if (rv != APR_SUCCESS) {
179 Q_DBG(
"sig !empty", queue);
180 rv = fspr_thread_cond_signal(queue->
not_empty);
181 if (rv != APR_SUCCESS) {
205 if (rv != APR_SUCCESS) {
219 Q_DBG(
"sig !empty", queue);
220 rv = fspr_thread_cond_signal(queue->
not_empty);
221 if (rv != APR_SUCCESS) {
253 if (rv != APR_SUCCESS) {
263 if (rv != APR_SUCCESS) {
270 Q_DBG(
"queue empty (intr)", queue);
272 if (rv != APR_SUCCESS) {
284 *data = queue->
data[queue->
out];
289 Q_DBG(
"signal !full", queue);
290 rv = fspr_thread_cond_signal(queue->
not_full);
291 if (rv != APR_SUCCESS) {
316 if (rv != APR_SUCCESS) {
327 if (rv != APR_SUCCESS) {
334 Q_DBG(
"queue empty (intr)", queue);
336 if (rv != APR_SUCCESS) {
348 *data = queue->
data[queue->
out];
353 Q_DBG(
"signal !full", queue);
354 rv = fspr_thread_cond_signal(queue->
not_full);
355 if (rv != APR_SUCCESS) {
380 if (rv != APR_SUCCESS) {
389 *data = queue->
data[queue->
out];
394 Q_DBG(
"signal !full", queue);
395 rv = fspr_thread_cond_signal(queue->
not_full);
396 if (rv != APR_SUCCESS) {
409 Q_DBG(
"intr all", queue);
410 if ((rv = fspr_thread_mutex_lock(queue->
one_big_mutex)) != APR_SUCCESS) {
413 fspr_thread_cond_broadcast(queue->
not_empty);
414 fspr_thread_cond_broadcast(queue->
not_full);
416 if ((rv = fspr_thread_mutex_unlock(queue->
one_big_mutex)) != APR_SUCCESS) {
427 if ((rv = fspr_thread_mutex_lock(queue->
one_big_mutex)) != APR_SUCCESS) {
436 if ((rv = fspr_thread_mutex_unlock(queue->
one_big_mutex)) != APR_SUCCESS) {
fspr_status_t switch_apr_queue_trypush(switch_apr_queue_t *queue, void *data)
static fspr_status_t queue_destroy(void *data)
#define apr_queue_full(queue)
fspr_status_t switch_apr_queue_interrupt_all(switch_apr_queue_t *queue)
fspr_thread_cond_t * not_empty
fspr_thread_cond_t * not_full
fspr_status_t switch_apr_queue_pop_timeout(switch_apr_queue_t *queue, void **data, fspr_interval_time_t timeout)
unsigned int switch_apr_queue_size(switch_apr_queue_t *queue)
fspr_status_t switch_apr_queue_push(switch_apr_queue_t *queue, void *data)
fspr_status_t switch_apr_queue_term(switch_apr_queue_t *queue)
if((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen)
fspr_thread_mutex_t * one_big_mutex
#define apr_queue_empty(queue)
unsigned int full_waiters
fspr_status_t switch_apr_queue_trypop(switch_apr_queue_t *queue, void **data)
fspr_status_t switch_apr_queue_pop(switch_apr_queue_t *queue, void **data)
fspr_status_t switch_apr_queue_create(switch_apr_queue_t **q, unsigned int queue_capacity, fspr_pool_t *a)
unsigned int empty_waiters