thread_pool_destroy()

Free the memory allocated to a thread pool

Synopsis:

#include <sys/iofunc.h>
#include <sys/dispatch.h>

int thread_pool_destroy( thread_pool_t * 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_destroy() function frees the memory allocated to a thread pool that's identified by the handle pool. This is done only after all the threads of the thread pool have exited.

The thread_pool_destroy() function calls the unblock handler provided in the pool attribute structure. The unblock handler is called at least once for every thread in the thread pool. Once the unblock handler is called, the thread calling thread_pool_destroy() blocks until the number of threads in the thread pool drops to zero. When there are no more threads in the thread pool, the handle pool is freed and thread_pool_destroy() returns.

A side effect of this behavior is that a thread that's created by the thread pool can't call thread_pool_destroy() because the thread pool count will never drop to zero, and subsequently the function will never return.

Returns:

0
Success.
-1
An error occurred.

Examples:

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

int main( int argc, char **argv ) {
   thread_pool_t        *tpp;

   …

   thread_pool_destroy ( tpp );
}

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

Classification:

QNX Neutrino

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

Last modified: 2013-12-23

comments powered by Disqus