Shadow Network Framework
0.0.1-alpha
C Server Library for Shadow Network Framework
|
this file Defines everything related to ThreadPool More...
Go to the source code of this file.
Data Structures | |
struct | SNF_ThreadPool_work_t |
Defines the 'work' needed to do by defining a 'func'tion and it's 'arg'ument. More... | |
struct | SNF_ThreadPool_worker_t |
Defines the 'worker'that would handle a certain 'work'. More... | |
struct | SNF_ThreadPool_t |
The structure for a Thread Pool. More... | |
Typedefs | |
typedef struct SNF_ThreadPool_work_t | SNF_thpool_work |
typedef struct SNF_ThreadPool_worker_t | SNF_thpool_worker |
typedef struct SNF_ThreadPool_t | thpool |
Functions | |
int | snf_thpool_inis (thpool **ThreadPool, int Max_Threads, void *(*Main_Worker)(), void *arg) |
Insitanciates a new thread pool, with a Limiter ( Max_Threads ) | |
void | snf_thpool_addwork (thpool *pool, void *(*func)(), void *arg) |
Creates a "work" that will call the func function with argument arg | |
void | snf_thpool_wait (thpool *pool) |
Blocks current thread until there is No "Worker" is working and no "work" is waiting in queue. | |
void | snf_thpool_join (thpool *pool) |
Will Block till the Main_worker finishes. | |
void | snf_thpool_stop (thpool *pool) |
will stop creating "workers" and wait till all already exising "workers" finish their "work" | |
this file Defines everything related to ThreadPool
Thread Pools By Abdelhadi Seddar This implemantation of a Threadpool is by no means perfect nor optimized, because I made it based of a graph depicting how a threadpool works, without seeing any documentation about it, this is just a learning experience for me and im learning through trial and error
typedef struct SNF_ThreadPool_work_t SNF_thpool_work |
typedef struct SNF_ThreadPool_worker_t SNF_thpool_worker |
typedef struct SNF_ThreadPool_t thpool |
|
extern |
Insitanciates a new thread pool, with a Limiter ( Max_Threads )
ThreadPool | Returns the thread pool by writes the newly created instance in the pointer given in this parameter |
Max_Threads | Maximum Total allowed threads ( Must be 2+ if No Main Worker given, else must me 3+ for proper work) |
Main_Worker | Main Function that would be called upon finishing the intialisation of the |
arg | the argument that would be given to the Main_worker function. |
|
extern |
Creates a "work" that will call the func function with argument arg
pool | The Thead Pool to be operated on. |
func | The function that would be called once a "worker" picks up the "work". |
arg | argument to be given to the func upon call. |
|
extern |
Blocks current thread until there is No "Worker" is working and no "work" is waiting in queue.
pool | The Thead Pool to be operated on. |
|
extern |
Will Block till the Main_worker finishes.
pool | The Thead Pool to be operated on. |
|
extern |
will stop creating "workers" and wait till all already exising "workers" finish their "work"
pool | The Thead Pool to be operated on. |