| 70 | } |
| 71 | |
| 72 | static void cull_zombies() { |
| 73 | if (pthread_mutex_trylock(&zombie_list_head.mutex) != 0) { |
| 74 | // Some other thread is already culling. In principle there may be new |
| 75 | // cullable zombies after it finishes, but it's not worth waiting to find |
| 76 | // out. |
| 77 | return; |
| 78 | } |
| 79 | em_task_queue* curr = zombie_list_head.zombie_next; |
| 80 | while (curr != &zombie_list_head) { |
| 81 | em_task_queue* next = curr->zombie_next; |
| 82 | if (curr->notification == NOTIFICATION_NONE) { |
| 83 | // Remove the zombie from the list and free it. |
| 84 | curr->zombie_prev->zombie_next = curr->zombie_next; |
| 85 | curr->zombie_next->zombie_prev = curr->zombie_prev; |
| 86 | em_task_queue_free(curr); |
| 87 | } |
| 88 | curr = next; |
| 89 | } |
| 90 | pthread_mutex_unlock(&zombie_list_head.mutex); |
| 91 | } |
| 92 | |
| 93 | em_task_queue* em_task_queue_create(pthread_t thread) { |
| 94 | // Free any queue that has been destroyed and is safe to free. |
no test coverage detected