|
Thread pool
|
#include <semaphore.h>#include <signal.h>#include <stdbool.h>#include <stddef.h>

Go to the source code of this file.
Data Structures | |
| struct | runnable |
| Runnable function. More... | |
| struct | node |
| Single queue node. More... | |
| struct | queue |
| Standard FIFO queue. More... | |
| struct | thread_pool |
| Thread-pool. More... | |
Typedefs | |
| typedef struct runnable | runnable_t |
| Runnable function. | |
| typedef struct node | node_t |
| Single queue node. | |
| typedef struct queue | queue_t |
| Standard FIFO queue. | |
| typedef struct thread_pool | thread_pool_t |
| Thread-pool. | |
Functions | |
| int | thread_pool_init (thread_pool_t *pool, size_t pool_size) |
| Initialize the thread-pool. More... | |
| void | thread_pool_destroy (thread_pool_t *pool) |
| Destroy the thread-pool. More... | |
| int | defer (thread_pool_t *pool, runnable_t runnable) |
| Add a new task to the pool. More... | |
Threadpool header file.
| int defer | ( | thread_pool_t * | pool, |
| runnable_t | runnable | ||
| ) |
Add a new task to the pool.
| [in,out] | pool | – pointer to thread-pool; |
| [in] | runnable | – task that will be run on the pool. |
0, if defer was finished correctly. Non-zero value, if errors occurred. 
| void thread_pool_destroy | ( | thread_pool_t * | pool | ) |
Destroy the thread-pool.
Finish all of the tasks and remove the pool.
| [in,out] | pool | – pointer to the thread-pool; |

| int thread_pool_init | ( | thread_pool_t * | pool, |
| size_t | pool_size | ||
| ) |
Initialize the thread-pool.
Create a thread_pool_t object at argument pool with number of thread passed as pool_size argument.
| [in,out] | pool | – pointer to the thread-pool; |
| [in] | pool_size | – size of the thread-pool; |
0, if init was finished correctly. Non-zero value, if errors occurred. 
1.8.17