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
60DECLEXPORT PSC_ThreadJob *
61PSC_ThreadJob_create(PSC_ThreadProc proc, void *arg, int timeoutTicks)
62 ATTR_NONNULL((1)) ATTR_RETNONNULL;
63
71DECLEXPORT PSC_Event *
72PSC_ThreadJob_finished(PSC_ThreadJob *self)
73 CMETHOD ATTR_RETNONNULL ATTR_PURE;
74
82DECLEXPORT int
83PSC_ThreadJob_hasCompleted(const PSC_ThreadJob *self)
84 CMETHOD ATTR_PURE;
85
94DECLEXPORT void
95PSC_ThreadJob_destroy(PSC_ThreadJob *self);
96
104DECLEXPORT int
105PSC_ThreadJob_canceled(void);
106
114DECLEXPORT PSC_AsyncTask *
115PSC_AsyncTask_create(PSC_AsyncTaskJob job);
116
123DECLEXPORT void *
124PSC_AsyncTask_await(PSC_AsyncTask *self, void *arg);
125
133DECLEXPORT void *
134PSC_AsyncTask_arg(PSC_AsyncTask *self);
135
143DECLEXPORT void
144PSC_AsyncTask_complete(PSC_AsyncTask *self, void *result);
145
152DECLEXPORT void
153PSC_ThreadOpts_init(int defThreads);
154
160DECLEXPORT void
161PSC_ThreadOpts_fixedThreads(int n);
162
171DECLEXPORT void
172PSC_ThreadOpts_threadsPerCpu(int n);
173
179DECLEXPORT void
180PSC_ThreadOpts_maxThreads(int n);
181
187DECLEXPORT void
188PSC_ThreadOpts_fixedQueue(int n);
189
197DECLEXPORT void
198PSC_ThreadOpts_queuePerThread(int n);
199
205DECLEXPORT void
206PSC_ThreadOpts_maxQueue(int n);
207
213DECLEXPORT void
214PSC_ThreadOpts_minQueue(int n);
215
223DECLEXPORT int
224PSC_ThreadPool_init(void);
225
231DECLEXPORT int
232PSC_ThreadPool_active(void);
233
244DECLEXPORT int
245PSC_ThreadPool_enqueue(PSC_ThreadJob *job)
246 ATTR_NONNULL((1));
247
257DECLEXPORT void
258PSC_ThreadPool_cancel(PSC_ThreadJob *job)
259 ATTR_NONNULL((1));
260
266DECLEXPORT void
267PSC_ThreadPool_done(void);
268
269#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