HTL_thread_pool_pop_with_context
Pops up the worker from the pool with the context.
Interface Definition
int HTL_thread_pool_pop_with_context(HTL_thread_pool_t thread_pool, HTL_worker_t *worker, uint64_t pool_context);
Description
HTL_thread_pool_pop_with_context() pops up the worker from the pool specified by thread_pool with the context and sets it as worker.
If the function successfully pops up the worker, the function set worker to the obtained HTL_worker_t handle. Otherwise, this function sets worker to HTL_THREAD_WORKER_NULL. The context type is user-defined.
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
thread_pool |
HTL_thread_pool_t |
Handle to the thread pool. |
Input |
worker |
HTL_worker_t * |
Address of the handle to the worker. |
Output |
pool_context |
uint64_t |
Operation mode. |
Input |
Return Value
- HTL_THREAD_SUCCESS: success.
- Other values: failure. For details, see the error code descriptions.
Example
1 2 3 4 5 | int num_pools; HTL_thread_pool_t *pools; pools = (HTL_thread_pool_t *)malloc(num_pools * sizeof(HTL_thread_pool_t)); HTL_thread_scheduler_get_pools(sched, num_pools, 0, pools); HTL_thread_pool_pop_with_context(pools[0], &unit, 0); |
Parent topic: Thread Pool Functions