Go to the source code of this file.
◆ alloc()
static ANN bool alloc |
( |
threadpool_t * | p, |
|
|
const uint32_t | thread_count, |
|
|
const uint32_t | queue_size ) |
|
static |
◆ ANN2()
Definition at line 81 of file threadpool.c.
81 {
82 if(
unlikely(p->shutdown || p->active == p->queue_size))
83 return false;
84 const uint32_t next = (p->tail + 1) % p->queue_size;
86 p->queue[p->tail] = t;
87 p->tail = next;
88 p->active++;
90 return true;
91}
static ANN int gwt_signal(gwtcond_t *cond)
◆ free_threadpool()
Definition at line 100 of file threadpool.c.
100 {
106 for(uint32_t i = 0; i < p->
started; i++)
109 }
113}
static ANN void gwt_cond_end(gwtcond_t *cond)
static ANN int gwt_broadcast(gwtcond_t *cond)
static ANN int gwt_unlock(gwtlock_t *lock)
static ANN void gwt_join(gwtthread_t thread)
static ANN void gwt_lock_end(gwtlock_t *lock)
static ANN int gwt_lock(gwtlock_t *lock)
◆ new_threadpool()
threadpool_t * new_threadpool |
( |
const uint32_t | thread_count, |
|
|
const uint32_t | queue_size ) |
Definition at line 66 of file threadpool.c.
66 {
68 if(!p) return NULL;
73 if(
alloc(p, thread_count, queue_size) || !
utils(p) ||
74 !
start(p, thread_count)) {
76 return NULL;
77 }
78 return p;
79}
static ANN bool start(threadpool_t *p, const uint32_t thread_count)
static ANN bool utils(threadpool_t *p)
static ANN bool alloc(threadpool_t *p, const uint32_t thread_count, const uint32_t queue_size)
ANN void free_threadpool(threadpool_t *p)
◆ start()
Definition at line 57 of file threadpool.c.
57 {
58 for(uint32_t i = 0; i < thread_count; i++) {
60 if(ret) return false;
62 }
63 return true;
64}
static ANN gwtreturn_t threadpool_thread(void *data)
static ANN bool gwt_create(gwtthread_t *thread, gwtreturn_t(*fun)(void *), void *arg)
◆ threadpool_add()
bool threadpool_add |
( |
threadpool_t * | p, |
|
|
void(*)(void *) | fun, |
|
|
void * | arg ) |
Definition at line 93 of file threadpool.c.
93 {
95 const bool ret = add(p, fun,
arg);
97 return ret;
98}
◆ threadpool_thread()
Definition at line 23 of file threadpool.c.
23 {
25 while(true) {
34 task.fun(task.arg);
35 }
38}
#define THREAD_RETURN(arg)
static ANN void gwt_wait(gwtcond_t *cond, gwtlock_t *lock)
◆ utils()
Definition at line 46 of file threadpool.c.
46 {
47#ifdef BUILD_ON_WINDOWS
49#endif
54 return true;
55}
static ANN int gwt_cond_ini(gwtcond_t *cond)
static ANN int gwt_lock_ini(gwtlock_t *lock)