Memclave Artifact Documentation
Loading...
Searching...
No Matches
vud_pool.h File Reference
#include <pthread.h>
#include <stdbool.h>

Go to the source code of this file.

Typedefs

typedef void(* vud_pool_worker) (unsigned id, unsigned nr_worker, void *arg)
 called once per pool_do call for each worker
 
typedef struct vud_pool vud_pool
 

Functions

vud_poolvud_pool_init (unsigned n_worker)
 create a new thread pool
 
void vud_pool_do (vud_pool *pool, vud_pool_worker worker, void *arg)
 perform an operation on all workers of the pool
 
void vud_pool_free (vud_pool *pool)
 free up all resources (including threads and locks) used for the pool
 

Typedef Documentation

◆ vud_pool

typedef struct vud_pool vud_pool

a simple thread pool implementation used for parallel memory accesses

◆ vud_pool_worker

typedef void(* vud_pool_worker) (unsigned id, unsigned nr_worker, void *arg)

called once per pool_do call for each worker

Parameters
idID of the worker - The id is between 0 and the worker count minus 1
nr_workernumber of workers in the current pool
argargument passed via pool_do

Function Documentation

◆ vud_pool_do()

void vud_pool_do ( vud_pool pool,
vud_pool_worker  worker,
void *  arg 
)

perform an operation on all workers of the pool

Parameters
poolthread pool to perform operation with
workerfunction pointer to the operation to perform
argargument passed to all worker threads

◆ vud_pool_free()

void vud_pool_free ( vud_pool pool)

free up all resources (including threads and locks) used for the pool

◆ vud_pool_init()

vud_pool * vud_pool_init ( unsigned  n_worker)

create a new thread pool

This will spawn n_worker - 1 threads in the background, which will immediately block on a barrier waiting for something to do.

Parameters
n_workernumber of workers in the pool
Returns
a thread pool on success or NULL on failure