Thread pool
Data Structures | Typedefs | Functions
threadpool.h File Reference
#include <semaphore.h>
#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for threadpool.h:
This graph shows which files directly or indirectly include this file:

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...
 

Detailed Description

Threadpool header file.

Author
Michał Niedziółka micha.nosp@m.l.ni.nosp@m.edzio.nosp@m.lka@.nosp@m.stude.nosp@m.nts..nosp@m.mimuw.nosp@m..edu.nosp@m..pl
Date
11.02.2020

Function Documentation

◆ defer()

int defer ( thread_pool_t pool,
runnable_t  runnable 
)

Add a new task to the pool.

Parameters
[in,out]pool– pointer to thread-pool;
[in]runnable– task that will be run on the pool.
Returns
0, if defer was finished correctly. Non-zero value, if errors occurred.
Here is the call graph for this function:

◆ thread_pool_destroy()

void thread_pool_destroy ( thread_pool_t pool)

Destroy the thread-pool.

Finish all of the tasks and remove the pool.

Parameters
[in,out]pool– pointer to the thread-pool;
Here is the call graph for this function:

◆ thread_pool_init()

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.

Parameters
[in,out]pool– pointer to the thread-pool;
[in]pool_size– size of the thread-pool;
Returns
0, if init was finished correctly. Non-zero value, if errors occurred.
Here is the call graph for this function: