Provided by: liblibrecast-dev_0.8.0-1.1build1_amd64 bug

NAME

       q_pool_create, q_pool_destroy - initialize and destroy thread pools

LIBRARY

       Librecast library (liblibrecast, -llibrecast)

SYNOPSIS

       #include <librecast/q.h>

       int q_pool_create(pthread_t tid[], int nthreads, void *(*f)(void *), void *restrict arg);
       int q_pool_destroy(pthread_t tid[], int nthreads);

       Compile and link with -llibrecast.

DESCRIPTION

       The q_pool_create() function creates a thread pool of nthreads threads, using f and arg as
       the start_routine and argument for each thread.

       q_pool_create() is designed for use with q_job_seek(3) to start a thread pool  of  workers
       to process jobs from a smolq queue.

       The  q_pool_destroy()  function  is  called  to  cancel  and reap the threads created with
       q_pool_create(3).

       tid must be an array of pthread_t of size nthreads.

RETURN VALUE

       These functions return zero on success. On error, the number of  threads  that  failed  to
       start or stop is returned and errno is set to indicate the error.

       If  q_pool_create() successfully starts any threads, these are not cancelled if there is a
       failure starting a later thread. Call q_pool_destroy(3) to  destroy  the  created  threads
       when done, passing nthreads minus the return value from the failed call to q_pool_create()
       to stop the running threads.

ERRORS

       q_pool_create() may fail with any of the errors for pthread_create(3).

SEE ALSO

       q_job_seek(3), q_push(3), q_wait(3), sem_init(3), sem_destroy(3), pthread_create(3)