static void schedule_thread_post_mortem(struct thread *corpse) { struct thread_post_mortem *post_mortem = NULL; if (corpse) { post_mortem = plan_thread_post_mortem(corpse); #ifdef CREATE_POST_MORTEM_THREAD pthread_t thread; int result = pthread_create(&thread, NULL, perform_thread_post_mortem, post_mortem); gc_assert(!result); #else post_mortem = (struct thread_post_mortem *) swap_lispobjs((lispobj *)(void *)&pending_thread_post_mortem, (lispobj)post_mortem); perform_thread_post_mortem(post_mortem); #endif } }
static void schedule_thread_post_mortem(struct thread *corpse) { struct thread_post_mortem *post_mortem = NULL; if (corpse) { post_mortem = plan_thread_post_mortem(corpse); #ifdef DELAY_THREAD_POST_MORTEM pthread_mutex_lock(&thread_post_mortem_lock); /* First stick the new post mortem to the end of the queue. */ if (pending_thread_post_mortem) { struct thread_post_mortem *next = pending_thread_post_mortem; while (next->next) { next = next->next; } next->next = post_mortem; } else { pending_thread_post_mortem = post_mortem; } /* Then, if there are enough things in the queue, clean up one * from the head -- or increment the count, and null out the * post_mortem we have. */ if (pending_thread_post_mortem_count > DELAY_THREAD_POST_MORTEM) { post_mortem = pending_thread_post_mortem; pending_thread_post_mortem = post_mortem->next; } else { pending_thread_post_mortem_count++; post_mortem = NULL; } pthread_mutex_unlock(&thread_post_mortem_lock); /* Finally run, the cleanup, if any. */ perform_thread_post_mortem(post_mortem); #elif defined(CREATE_POST_MORTEM_THREAD) gc_assert(!pthread_create(&thread, NULL, perform_thread_post_mortem, post_mortem)); #else post_mortem = (struct thread_post_mortem *) swap_lispobjs((lispobj *)(void *)&pending_thread_post_mortem, (lispobj)post_mortem); perform_thread_post_mortem(post_mortem); #endif } }