[Previous] [Contents] [Index] [Next]

thread_pool_start()

Start a thread pool

Synopsis:

#include <sys/dispatch.h>

int thread_pool_start( void *pool );

Library:

libc

Description:

The function thread_pool_start() starts the thread pool pool. The function may or may not return, depending on the flags passed to thread_pool_create().

Returns:

EOK
Success.
-1
An error occurred.

Examples:

#include <sys/dispatch.h>
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char **argv ) {
   thread_pool_attr_t   pool_attr;
   thread_pool_t        *tpp;
   dispatch_t           *dpp;
   resmgr_attr_t        attr;
   resmgr_context_t     *ctp;

   if( (dpp = dispatch_create()) == NULL ) {
     fprintf( stderr, "%s: Unable to allocate \
              dispatch context.\n", argv[0] );
     return EXIT_FAILURE;
   }

   memset( &pool_attr, 0, sizeof (pool_attr) );
   pool_attr.handle = dpp;
   /* We are only doing resmgr-type attach */
   pool_attr.context_alloc = resmgr_context_alloc;
   pool_attr.block_func = resmgr_block;
   pool_attr.handler_func = resmgr_handler;
   pool_attr.context_free = resmgr_context_free;
   pool_attr.lo_water = 2;
   pool_attr.hi_water = 4;
   pool_attr.increment = 1;
   pool_attr.maximum = 50;

   if( (tpp = thread_pool_create( &pool_attr,
              POOL_FLAG_EXIT_SELF )) == NULL ) {
     fprintf( stderr, "%s: Unable to initialize \
              thread pool.\n", argv[0] );
     return EXIT_FAILURE;
   }

   ...

   /* Never returns */
   thread_pool_start( tpp );
}

For examples using the dispatch interface, see dispatch_create(), message_attach(), resmgr_attach(), and thread_pool_create().

Classification:

QNX 6

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

thread_pool_create(), thread_pool_destroy()


[Previous] [Contents] [Index] [Next]