| 120 | return nt; |
| 121 | } |
| 122 | void addTask(Task *nt) { |
| 123 | if (!finished) { |
| 124 | pthread_mutex_lock(&qmtx); |
| 125 | tasks.push(nt); |
| 126 | pthread_cond_signal(&wcond); |
| 127 | pthread_mutex_unlock(&qmtx); |
| 128 | } |
| 129 | } |
| 130 | void finish() { |
| 131 | pthread_mutex_lock(&qmtx); |
| 132 | finished = true; |