Implementing A Thread Pool (Cont.) /* data structure for a request. */ struct request { ... }; /* the requests queue. */ struct request_queue { pthread_mutex_t* mutex; /* for mutual exclusion. */ pthread_cond_t* cond; /* for queue change notifications. */ ... }; /* data structure used to hold a threads' data. */ struct handler_thread_data { int thread_id; /* for debugging. */ requests_queue* q; /* the pool's queue. */ int should_exit; /* should _i_ exit */ int* pool_exit; /* all pool exits. */ };