 | | The body of the routine is a loop in which the worker checks the request queue. If it's empty, the worker sleeps on the queue_not_empty condition variable. It can be awakened by either a shutdown request from tpool_destroy or a work item placed on its request queue. When awakened by a shutdown request, the worker exits. When awakened by a work request, however, it rechecks the queue, removes the request from the queue's head, and executes the routine specified in the request (using any associated argument). If the worker finds that the queue was full before it removed the node and knows that threads may be blocked waiting to add to the queue (because the pool's do_not_block_when_full characteristic is not set), it signals the queue_not_full condition. Likewise, if this thread empties the queue, it signals queue_empty to allow a delayed shutdown to proceed. | |
|