FreeBSD/cddl/compat/opensolaris/misc/thread_pool.c
/*
 * Wait for all jobs to complete.
 * Calling tpool_wait() from a job in the pool will cause deadlock.
 */
Wait for all jobs to complete.
Calling tpool_wait() from a job in the pool will cause deadlock.
Wait for all jobs to complete . Calling tpool_wait () from a job in the pool will cause deadlock .
void
tpool_wait(tpool_t *tpool)
{
	pthread_mutex_lock(&tpool->tp_mutex);
	pthread_cleanup_push((_Voidfp)pthread_mutex_unlock, &tpool->tp_mutex);
	while (tpool->tp_head != NULL || tpool->tp_active != NULL) {
		tpool->tp_flags |= TP_WAIT;
		(void) pthread_cond_wait(&tpool->tp_waitcv, &tpool->tp_mutex);
	}
	pthread_cleanup_pop(1);	
}
void tpool_wait ( tpool_t * tpool ) { pthread_mutex_lock ( & tpool -> tp_mutex ) ; pthread_cleanup_push ( ( _Voidfp ) pthread_mutex_unlock , & tpool -> tp_mutex ) ; while ( tpool -> tp_head != NULL || tpool -> tp_active != NULL ) { tpool -> tp_flags |= TP_WAIT ; ( void ) pthread_cond_wait ( & tpool -> tp_waitcv , & tpool -> tp_mutex ) ; } pthread_cleanup_pop ( 1 ) ; }
Wait for all jobs to complete.
Wait for all jobs to complete .
/* pthread_mutex_unlock(&tpool->tp_mutex); */