diff --git a/janus/src/queue.c b/janus/src/queue.c index e0ce03b..ccb0423 100644 --- a/janus/src/queue.c +++ b/janus/src/queue.c @@ -76,7 +76,7 @@ int us_queue_put(us_queue_s *queue, void *item, long double timeout) { ++queue->in; queue->in %= queue->capacity; US_MUTEX_UNLOCK(queue->mutex); - assert(!pthread_cond_broadcast(&queue->empty_cond)); + US_COND_BROADCAST(queue->empty_cond); return 0; } @@ -88,7 +88,7 @@ int us_queue_get(us_queue_s *queue, void **item, long double timeout) { ++queue->out; queue->out %= queue->capacity; US_MUTEX_UNLOCK(queue->mutex); - assert(!pthread_cond_broadcast(&queue->full_cond)); + US_COND_BROADCAST(queue->full_cond); return 0; } diff --git a/src/libs/threading.h b/src/libs/threading.h index 6a346af..b61c623 100644 --- a/src/libs/threading.h +++ b/src/libs/threading.h @@ -67,6 +67,7 @@ #define US_COND_INIT(x_cond) assert(!pthread_cond_init(&(x_cond), NULL)) #define US_COND_DESTROY(x_cond) assert(!pthread_cond_destroy(&(x_cond))) #define US_COND_SIGNAL(x_cond) assert(!pthread_cond_signal(&(x_cond))) +#define US_COND_BROADCAST(x_cond) assert(!pthread_cond_broadcast(&(x_cond))) #define US_COND_WAIT_FOR(x_var, x_cond, x_mutex) { while(!(x_var)) assert(!pthread_cond_wait(&(x_cond), &(x_mutex))); }