Coding style change
This commit is contained in:
@@ -53,23 +53,23 @@ int uc_thread_queue_add(struct uc_threadqueue *queue, struct uc_threadmsg *msg)
|
||||
|
||||
//insert the new element
|
||||
msg->next = NULL;
|
||||
if(msg->msgtype >= 0) { //add at the tail
|
||||
if (msg->msgtype >= 0) { //add at the tail
|
||||
*(queue->last) = msg;
|
||||
queue->last = &msg->next;
|
||||
} else { //add at the head ("priority message")
|
||||
msg->next = queue->first;
|
||||
if(queue->first == NULL) {
|
||||
if (queue->first == NULL) {
|
||||
queue->last = &msg->next;
|
||||
}
|
||||
queue->first = msg;
|
||||
}
|
||||
|
||||
//signal blocked readers
|
||||
if(queue->num_read_waiters == 1) {
|
||||
if (queue->num_read_waiters == 1) {
|
||||
//if there's just one thread waiting to pop elements
|
||||
//use _cond_signal. _cond_broadcast can be more expensive (os dependent)
|
||||
pthread_cond_signal(&queue->read_cond);
|
||||
} else if(queue->num_read_waiters > 1) {
|
||||
} else if (queue->num_read_waiters > 1) {
|
||||
//signall all threads that there's items available.
|
||||
pthread_cond_broadcast(&queue->read_cond);
|
||||
}
|
||||
@@ -127,18 +127,18 @@ int uc_thread_queue_get(struct uc_threadqueue *queue, const struct timespec *tim
|
||||
//remove the first element
|
||||
first_msg = queue->first;
|
||||
queue->first = first_msg->next;
|
||||
if(queue->first == NULL)
|
||||
if (queue->first == NULL)
|
||||
queue->last = &queue->first;
|
||||
first_msg->next = NULL;
|
||||
|
||||
queue->num_elements--;
|
||||
|
||||
//signal blocked writers
|
||||
if(queue->num_write_waiters == 1) {
|
||||
if (queue->num_write_waiters == 1) {
|
||||
//if there's just one thread waiting to push elements
|
||||
//use _cond_signal. _cond_broadcast can be more expensive (os dependent)
|
||||
pthread_cond_signal(&queue->write_cond);
|
||||
} else if(queue->num_write_waiters > 1) {
|
||||
} else if (queue->num_write_waiters > 1) {
|
||||
//signall all threads that there's items available.
|
||||
pthread_cond_broadcast(&queue->write_cond);
|
||||
}
|
||||
@@ -192,12 +192,12 @@ int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_f
|
||||
* But if we *know* there are some threads still using the queue,
|
||||
* we can't destroy it.
|
||||
*/
|
||||
if(queue->num_read_waiters != 0 || queue->num_write_waiters != 0) {
|
||||
if (queue->num_read_waiters != 0 || queue->num_write_waiters != 0) {
|
||||
pthread_mutex_unlock(&queue->mutex);
|
||||
return EBUSY;
|
||||
}
|
||||
|
||||
if(free_func) {
|
||||
if (free_func) {
|
||||
uc_thread_queue_walk_unlocked(queue, free_func);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user