| 70 | } |
| 71 | |
| 72 | void* dequeue() |
| 73 | { |
| 74 | node_t* n = 0; |
| 75 | |
| 76 | pthread_mutex_lock(&mtx); |
| 77 | while (VAR(head) == 0) |
| 78 | pthread_cond_wait(&cv, &mtx); |
| 79 | n = VAR(head); |
| 80 | if (n->VAR(next) == 0) |
| 81 | VAR(tail) = 0; |
| 82 | VAR(head) = n->VAR(next); |
| 83 | pthread_mutex_unlock(&mtx); |
| 84 | |
| 85 | void* data = n->VAR(data); |
| 86 | delete n; |
| 87 | return data; |
| 88 | } |
| 89 | |
| 90 | private: |
| 91 | struct node_t |