cp_pooled_thread is a thread that lives in a thread_pool. More...
#include <thread.h>
Data Fields | |
| long | id |
| integral (implementation specific) thread id | |
| struct _cp_thread_pool * | owner |
| the pool this thread belongs to | |
| cp_thread * | worker |
| the actual thread | |
| cp_thread_action | action |
| thread function for the next assignment | |
| void * | action_prm |
| parameter for the next assignment | |
| cp_thread_stop_fn | stop_fn |
| called on cp_pooled_thread_stop | |
| void * | stop_prm |
| if not set, stop_fn invoked w/ action_prm | |
| cp_mutex * | suspend_lock |
| lock for framework scheduling | |
| cp_cond * | suspend_cond |
| condition variable for framework scheduling | |
| int | done |
| done flag | |
| int | wait |
| wait flag | |
cp_pooled_thread is a thread that lives in a thread_pool.
The struct holds synchronization elements used to control the thread and actuation settings, i.e. a thread function and a parameter to be passed for the next starting thread. The pool initializes a bunch of threads and sets them in 'wait'.
When a client requests threads from the pool, the next available thread is signalled out of 'wait', and runs the thread function requested by the client (see cp_thread_pool_get_impl). When the client thread function is done, the cp_pooled_thread returns to the thread pool and becomes available to pool clients. The cp_pooled_thread only exits when the pool exits, unless explicitly stopped (eg pthread_exit) by client code.
1.7.1