poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
threadpool.h
Go to the documentation of this file.
1#ifndef POSER_CORE_THREADPOOL_H
2#define POSER_CORE_THREADPOOL_H
3
8#include <poser/decl.h>
9
13C_CLASS_DECL(PSC_ThreadJob);
14
28C_CLASS_DECL(PSC_Event);
29
33typedef void (*PSC_ThreadProc)(void *arg);
34
44DECLEXPORT PSC_ThreadJob *
45PSC_ThreadJob_create(PSC_ThreadProc proc, void *arg, int timeoutTicks)
46 ATTR_NONNULL((1)) ATTR_RETNONNULL;
47
55DECLEXPORT PSC_Event *
56PSC_ThreadJob_finished(PSC_ThreadJob *self)
57 CMETHOD ATTR_RETNONNULL ATTR_PURE;
58
66DECLEXPORT int
67PSC_ThreadJob_hasCompleted(const PSC_ThreadJob *self)
68 CMETHOD ATTR_PURE;
69
78DECLEXPORT void
79PSC_ThreadJob_destroy(PSC_ThreadJob *self);
80
88DECLEXPORT int
89PSC_ThreadJob_canceled(void);
90
97DECLEXPORT void
98PSC_ThreadOpts_init(int defThreads);
99
105DECLEXPORT void
106PSC_ThreadOpts_fixedThreads(int n);
107
116DECLEXPORT void
117PSC_ThreadOpts_threadsPerCpu(int n);
118
124DECLEXPORT void
125PSC_ThreadOpts_maxThreads(int n);
126
132DECLEXPORT void
133PSC_ThreadOpts_fixedQueue(int n);
134
142DECLEXPORT void
143PSC_ThreadOpts_queuePerThread(int n);
144
150DECLEXPORT void
151PSC_ThreadOpts_maxQueue(int n);
152
158DECLEXPORT void
159PSC_ThreadOpts_minQueue(int n);
160
168DECLEXPORT int
169PSC_ThreadPool_init(void);
170
176DECLEXPORT int
177PSC_ThreadPool_active(void);
178
189DECLEXPORT int
190PSC_ThreadPool_enqueue(PSC_ThreadJob *job)
191 ATTR_NONNULL((1));
192
202DECLEXPORT void
203PSC_ThreadPool_cancel(PSC_ThreadJob *job)
204 ATTR_NONNULL((1));
205
211DECLEXPORT void
212PSC_ThreadPool_done(void);
213
214#endif
A simple event class.
A job to be executed on a worker thread.
PSC_ThreadJob * PSC_ThreadJob_create(PSC_ThreadProc proc, void *arg, int timeoutTicks)
Create a new thread job.
void(* PSC_ThreadProc)(void *arg)
A function to run on a worker thread.
Definition: threadpool.h:33