| 128 | } |
| 129 | |
| 130 | static struct work_item *get_work(void) |
| 131 | { |
| 132 | struct work_item *ret; |
| 133 | |
| 134 | grep_lock(); |
| 135 | while (todo_start == todo_end && !all_work_added) { |
| 136 | pthread_cond_wait(&cond_add, &grep_mutex); |
| 137 | } |
| 138 | |
| 139 | if (todo_start == todo_end && all_work_added) { |
| 140 | ret = NULL; |
| 141 | } else { |
| 142 | ret = &todo[todo_start]; |
| 143 | todo_start = (todo_start + 1) % ARRAY_SIZE(todo); |
| 144 | } |
| 145 | grep_unlock(); |
| 146 | return ret; |
| 147 | } |
| 148 | |
| 149 | static void work_done(struct work_item *w) |
| 150 | { |
no test coverage detected