Shadow Network Framework  0.0.1-alpha
C Server Library for Shadow Network Framework
Loading...
Searching...
No Matches
SNF_ThreadPool_t Struct Reference

The structure for a Thread Pool. More...

#include <SNF/thpool.h>

Data Fields

SNF_thpool_workthpool_works
 This LinkedList will store the "works" or "jobs".
 
_Atomic int thpool_n_works
 Defines current amount of currently awaiting "works".
 
SNF_thpool_workerthpool_workers
 This LinkedList will store the currently working "workers" or more exactly the worker thread info.
 
pthread_mutex_t thpool_works_MUTEX
 Used to synchronize the acces to thpool_works.
 
pthread_mutex_t thpool_workers_MUTEX
 Used to synchronize the acces to thpool_workers.
 
pthread_mutex_t thpool_noworks_MUTEX
 Used to synchronize if all "works" are handled and all "workers" had finished their assigned "work" See snf_thpool_wait(thpool *pool)
 
pthread_cond_t thpool_noworks_cond
 Used to synchronize if all "works" are handled and all "workers" had finished their assigned "work" See snf_thpool_wait(thpool *pool)
 
pthread_cond_t thpool_works_cond
 Used to synchronize the acces to thpool_works.
 
pthread_t * thpool_handler
 Thread that manages "workers" and assign their "work" to them.
 
pthread_t * thpool_main_worker
 The main function that is runs first when the Thread pool has started.
 
sem_t thpool_workers_sem
 Semaphore used for synchronization; Used primarly to notify the conclusion of "workers" to the Thread pool handler, and to Limit the amount of "worker" threads with the max being max_workers_count.
 
int max_workers_count
 Limiter for the amount of threads that could be created.
 
_Atomic int stop
 If set = 1 the thpool_handler will stop creating "workers" and wait till all already exising "workers" finish their "work".
 

Detailed Description

The structure for a Thread Pool.

Field Documentation

◆ thpool_works

SNF_thpool_work* SNF_ThreadPool_t::thpool_works

This LinkedList will store the "works" or "jobs".

◆ thpool_n_works

_Atomic int SNF_ThreadPool_t::thpool_n_works

Defines current amount of currently awaiting "works".

◆ thpool_workers

SNF_thpool_worker* SNF_ThreadPool_t::thpool_workers

This LinkedList will store the currently working "workers" or more exactly the worker thread info.

Note
Linked List saves SNF_ThreadPool_work_t . See SNF_ThreadPool_worker_t .

◆ thpool_works_MUTEX

pthread_mutex_t SNF_ThreadPool_t::thpool_works_MUTEX

Used to synchronize the acces to thpool_works.

Warning
Must not be touched or the Thread Pool may not work as intended

◆ thpool_workers_MUTEX

pthread_mutex_t SNF_ThreadPool_t::thpool_workers_MUTEX

Used to synchronize the acces to thpool_workers.

Warning
Must not be touched or the Thread Pool may not work as intended

◆ thpool_noworks_MUTEX

pthread_mutex_t SNF_ThreadPool_t::thpool_noworks_MUTEX

Used to synchronize if all "works" are handled and all "workers" had finished their assigned "work" See snf_thpool_wait(thpool *pool)

Note
Use snf_thpool_wait(thpool *pool) .

◆ thpool_noworks_cond

pthread_cond_t SNF_ThreadPool_t::thpool_noworks_cond

Used to synchronize if all "works" are handled and all "workers" had finished their assigned "work" See snf_thpool_wait(thpool *pool)

Note
Use snf_thpool_wait(thpool *pool) .

◆ thpool_works_cond

pthread_cond_t SNF_ThreadPool_t::thpool_works_cond

Used to synchronize the acces to thpool_works.

Warning
Must not be touched or the Thread Pool may not work as intended

◆ thpool_handler

pthread_t* SNF_ThreadPool_t::thpool_handler

Thread that manages "workers" and assign their "work" to them.

◆ thpool_main_worker

pthread_t* SNF_ThreadPool_t::thpool_main_worker

The main function that is runs first when the Thread pool has started.

◆ thpool_workers_sem

sem_t SNF_ThreadPool_t::thpool_workers_sem

Semaphore used for synchronization; Used primarly to notify the conclusion of "workers" to the Thread pool handler, and to Limit the amount of "worker" threads with the max being max_workers_count.

Warning
Must not be touched or the Thread Pool may not work as intended

◆ max_workers_count

int SNF_ThreadPool_t::max_workers_count

Limiter for the amount of threads that could be created.

Warning
Must not be touched or the Thread Pool may not work as intended

◆ stop

_Atomic int SNF_ThreadPool_t::stop

If set = 1 the thpool_handler will stop creating "workers" and wait till all already exising "workers" finish their "work".

Note
Use snf_thpool_stop(thpool *pool) .

The documentation for this struct was generated from the following file: