thread/m_threadpool.c
/*! Initialize the threadpool queue.
 *  \param pool           handle to initialized threadpool
 *  \param queue_max_size Max size of the queue.  Must be at least the size
 *                        of the number of threads.  If 0, will calculate an
 *                        optimal size based on the number of threads.  use
 *                        SIZE_MAX for unlimited;
 */
Initialize the threadpool queue.
\param pool           handle to initialized threadpool
\param queue_max_size Max size of the queue.  Must be at least the size
of the number of threads.  If 0, will calculate an
optimal size based on the number of threads.  use
SIZE_MAX for unlimited.
Initialize the threadpool queue . \ param pool handle to initialized threadpool \ param queue_max_size Max size of the queue . Must be at least the size of the number of threads . If 0 will calculate an optimal size based on the number of threads . use SIZE_MAX for unlimited .
static void M_threadpool_queue_init(M_threadpool_t *pool, size_t queue_max_size)
{
	size_t size         = queue_max_size;
	if (size == 0) {
		if (pool->max_threads < SIZE_MAX / THREADQUEUE_MULTIPLIER) {
			size = pool->max_threads * THREADQUEUE_MULTIPLIER;
		} else {
			size = SIZE_MAX;
		}
	}
	pool->queue          = M_llist_create(NULL, M_LLIST_NONE);
	pool->queue_max_size = size;
	pool->queue_waiters  = 0;
	pool->queue_lock     = M_thread_mutex_create(M_THREAD_MUTEXATTR_NONE);
	pool->queue_icond    = M_thread_cond_create(M_THREAD_CONDATTR_NONE);
	pool->queue_ocond    = M_thread_cond_create(M_THREAD_CONDATTR_NONE);
}
static void M_threadpool_queue_init ( M_threadpool_t * pool , size_t queue_max_size ) { size_t size = queue_max_size ; if ( size == 0 ) { if ( pool -> max_threads < SIZE_MAX / THREADQUEUE_MULTIPLIER ) { size = pool -> max_threads * THREADQUEUE_MULTIPLIER ; } else { size = SIZE_MAX ; } } pool -> queue = M_llist_create ( NULL , M_LLIST_NONE ) ; pool -> queue_max_size = size ; pool -> queue_waiters = 0 ; pool -> queue_lock = M_thread_mutex_create ( M_THREAD_MUTEXATTR_NONE ) ; pool -> queue_icond = M_thread_cond_create ( M_THREAD_CONDATTR_NONE ) ; pool -> queue_ocond = M_thread_cond_create ( M_THREAD_CONDATTR_NONE ) ; }
Initialize the threadpool queue.
Initialize the threadpool queue .
/* Make sure there is not an overflow in the calculation */