thread_pool_start()
QNX SDP8.0C Library ReferenceAPIDeveloper
Start a thread pool
Synopsis:
#include <sys/dispatch.h>
int thread_pool_start( void *pool );
Arguments:
- pool
- A thread pool handle that was returned by thread_pool_create().
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The thread_pool_start() function starts the thread pool pool. The function may or may not return, depending on the flags that you 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;
pool_attr.context_alloc = dispatch_context_alloc;
pool_attr.block_func = dispatch_block;
pool_attr.unblock_func = dispatch_unblock;
pool_attr.handler_func = dispatch_handler;
pool_attr.context_free = dispatch_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:
Safety: | |
---|---|
Cancellation point | Yes |
Signal handler | No |
Thread | Yes |
Page updated: