refactoring

This commit is contained in:
Maxim Devaev
2022-07-29 13:05:47 +03:00
parent 7b3dffd072
commit d2bef81b03
2 changed files with 3 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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))); }