Some initial work towards cutting down the number of fork calls we do

This commit is contained in:
ridiculousfish
2012-03-06 15:12:37 -08:00
parent 9ee4e4e05c
commit 36fe1e4a46
5 changed files with 21 additions and 3 deletions

View File

@@ -199,8 +199,14 @@ void iothread_service_completion(void) {
void iothread_drain_all(void) {
ASSERT_IS_MAIN_THREAD();
ASSERT_IS_NOT_FORKED_CHILD();
ASSERT_IS_NOT_FORKED_CHILD();
if (s_active_thread_count == 0)
return;
int thread_count = s_active_thread_count;
double now = timef();
while (s_active_thread_count > 0) {
iothread_service_completion();
}
double after = timef();
printf("(Waited %.02f msec for %d thread(s) to drain)\n", 1000 * (after - now), thread_count);
}