-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreadPool.h
More file actions
48 lines (42 loc) · 981 Bytes
/
threadPool.h
File metadata and controls
48 lines (42 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef _PTHREADPOOL_H_
#define _PTHREADPOOL_H_
typedef struct Threadpool Threadpool;
Threadpool* createThreadpool(int min, int max, int queueCapacity);
/**
* @brief a func to create a threadpool
* @param min the smallest amounts of live threads
* @param max the largest amounts of live threass,more than min ,less than max
* @param queueCapacity the larger amounts of task queue
* @return an Threadpool
*
*/
void manager(void* arg);
/**
* @brief it decides to kill live thread or create new thread
* @param arg a threadpool
*
*
*/
void worker(void* arg);
/**
* @brief it take an task from the taskQ, and then run its func
*
* @param arg a pool
*
*/
void exitThread(Threadpool* pool);
/**
* @brief exit threads and tuen their ids to zero
*
*/
void threadAdd(Threadpool* pool, void (*func)(void*arg), void* arg);
/**
* @brief insert some task into taskQ
*
*/
int threadPoolDestroyed(Threadpool* pool);
/**
* @brief destroy the pool
*
*/
#endif