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
24C_CLASS_DECL(PSC_AsyncTask);
25
39C_CLASS_DECL(PSC_Event);
40
44typedef void (*PSC_ThreadProc)(void *arg);
45
49typedef void (*PSC_AsyncTaskJob)(PSC_AsyncTask *task);
50
65DECLEXPORT PSC_ThreadJob *
66PSC_ThreadJob_create(PSC_ThreadProc proc, void *arg, int timeoutTicks)
67 ATTR_NONNULL((1)) ATTR_RETNONNULL;
68
82DECLEXPORT void
83PSC_ThreadJob_setStackSize(PSC_ThreadJob *self, size_t stackSize)
84 ATTR_NONNULL((1));
85
93DECLEXPORT PSC_Event *
94PSC_ThreadJob_finished(PSC_ThreadJob *self)
95 CMETHOD ATTR_RETNONNULL ATTR_PURE;
96
104DECLEXPORT int
105PSC_ThreadJob_hasCompleted(const PSC_ThreadJob *self)
106 CMETHOD ATTR_PURE;
107
116DECLEXPORT void
117PSC_ThreadJob_destroy(PSC_ThreadJob *self);
118
126DECLEXPORT int
127PSC_ThreadJob_canceled(void);
128
140DECLEXPORT int
141PSC_AsyncTask_awaitIsBlocking(void);
142
150DECLEXPORT PSC_AsyncTask *
151PSC_AsyncTask_create(PSC_AsyncTaskJob job);
152
159DECLEXPORT void *
160PSC_AsyncTask_await(PSC_AsyncTask *self, void *arg);
161
169DECLEXPORT void *
170PSC_AsyncTask_arg(PSC_AsyncTask *self);
171
179DECLEXPORT void
180PSC_AsyncTask_complete(PSC_AsyncTask *self, void *result);
181
188DECLEXPORT void
189PSC_ThreadOpts_init(int defThreads);
190
196DECLEXPORT void
197PSC_ThreadOpts_fixedThreads(int n);
198
207DECLEXPORT void
208PSC_ThreadOpts_threadsPerCpu(int n);
209
215DECLEXPORT void
216PSC_ThreadOpts_maxThreads(int n);
217
223DECLEXPORT void
224PSC_ThreadOpts_fixedQueue(int n);
225
233DECLEXPORT void
234PSC_ThreadOpts_queuePerThread(int n);
235
241DECLEXPORT void
242PSC_ThreadOpts_maxQueue(int n);
243
249DECLEXPORT void
250PSC_ThreadOpts_minQueue(int n);
251
259DECLEXPORT int
260PSC_ThreadPool_init(void);
261
267DECLEXPORT int
268PSC_ThreadPool_active(void);
269
280DECLEXPORT int
281PSC_ThreadPool_enqueue(PSC_ThreadJob *job)
282 ATTR_NONNULL((1));
283
293DECLEXPORT void
294PSC_ThreadPool_cancel(PSC_ThreadJob *job)
295 ATTR_NONNULL((1));
296
302DECLEXPORT void
303PSC_ThreadPool_done(void);
304
305#endif
An asynchronous task a thread job can wait for.
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_AsyncTaskJob)(PSC_AsyncTask *task)
A function to run for completing an asynchronous task.
Definition: threadpool.h:49
void(* PSC_ThreadProc)(void *arg)
A function to run on a worker thread.
Definition: threadpool.h:44