MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / cull_zombies

Function cull_zombies

system/lib/pthread/em_task_queue.c:72–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72static 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
93em_task_queue* em_task_queue_create(pthread_t thread) {
94 // Free any queue that has been destroyed and is safe to free.

Callers 1

em_task_queue_createFunction · 0.85

Calls 1

em_task_queue_freeFunction · 0.85

Tested by

no test coverage detected