CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
tqmthreadpool.h
1#pragma once
2// This header file is auto-generated!
3// Do not make changes to this file or they will be overwritten.
4// clang-format off
5#include <cx/obj.h>
6#include "tqmanager.h"
7#include <cx/taskqueue/worker/tqthreadworker.h>
8
9typedef struct TaskQueue TaskQueue;
10typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
11typedef struct TaskQueue TaskQueue;
12typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
13typedef struct TQThreadPoolRunner TQThreadPoolRunner;
14typedef struct TQThreadPoolRunner_WeakRef TQThreadPoolRunner_WeakRef;
15typedef struct TQThreadPoolManager TQThreadPoolManager;
16typedef struct TQThreadPoolManager_WeakRef TQThreadPoolManager_WeakRef;
17saDeclarePtr(TQThreadPoolManager);
18saDeclarePtr(TQThreadPoolManager_WeakRef);
19
20typedef struct TQThreadPoolManager_ClassIf {
21 ObjIface* _implements;
22 ObjIface* _parent;
23 size_t _size;
24
25 bool (*start)(_In_ void* self, _In_ TaskQueue* tq);
26 bool (*stop)(_In_ void* self);
27 void (*notify)(_In_ void* self, bool wakeup);
28 // for in-worker managers, this is called BEFORE a task is run by the worker
29 void (*pretask)(_In_ void* self);
30 int64 (*tick)(_In_ void* self);
31 void (*updatePoolSize)(_In_ void* self);
32} TQThreadPoolManager_ClassIf;
33extern TQThreadPoolManager_ClassIf TQThreadPoolManager_ClassIf_tmpl;
34
35typedef struct TQThreadPoolManager {
36 union {
37 TQThreadPoolManager_ClassIf* _;
38 void* _is_TQThreadPoolManager;
39 void* _is_TQManager;
40 void* _is_ObjInst;
41 };
42 ObjClassInfo* _clsinfo;
43 atomic(uintptr) _ref;
44 atomic(ptr) _weakref;
45
46 TaskQueue* tq;
47 bool needsWorkerTick; // true if this manager needs to be ticked by the worker
48 TQThreadPoolRunner* runner;
49 uint32 lastcount;
50 int64 lastop;
51 int64 idlestart;
52} TQThreadPoolManager;
53extern ObjClassInfo TQThreadPoolManager_clsinfo;
54#define TQThreadPoolManager(inst) ((TQThreadPoolManager*)(unused_noeval((inst) && &((inst)->_is_TQThreadPoolManager)), (inst)))
55#define TQThreadPoolManagerNone ((TQThreadPoolManager*)NULL)
56
57typedef struct TQThreadPoolManager_WeakRef {
58 union {
59 ObjInst* _inst;
60 void* _is_TQThreadPoolManager_WeakRef;
61 void* _is_TQManager_WeakRef;
62 void* _is_ObjInst_WeakRef;
63 };
64 atomic(uintptr) _ref;
65 RWLock _lock;
66} TQThreadPoolManager_WeakRef;
67#define TQThreadPoolManager_WeakRef(inst) ((TQThreadPoolManager_WeakRef*)(unused_noeval((inst) && &((inst)->_is_TQThreadPoolManager_WeakRef)), (inst)))
68
69// bool tqthreadpoolmanagerStart(TQThreadPoolManager* self, TaskQueue* tq);
70#define tqthreadpoolmanagerStart(self, tq) (self)->_->start(TQThreadPoolManager(self), TaskQueue(tq))
71// bool tqthreadpoolmanagerStop(TQThreadPoolManager* self);
72#define tqthreadpoolmanagerStop(self) (self)->_->stop(TQThreadPoolManager(self))
73// void tqthreadpoolmanagerNotify(TQThreadPoolManager* self, bool wakeup);
74#define tqthreadpoolmanagerNotify(self, wakeup) (self)->_->notify(TQThreadPoolManager(self), wakeup)
75// void tqthreadpoolmanagerPretask(TQThreadPoolManager* self);
76//
77// for in-worker managers, this is called BEFORE a task is run by the worker
78#define tqthreadpoolmanagerPretask(self) (self)->_->pretask(TQThreadPoolManager(self))
79// int64 tqthreadpoolmanagerTick(TQThreadPoolManager* self);
80#define tqthreadpoolmanagerTick(self) (self)->_->tick(TQThreadPoolManager(self))
81// void tqthreadpoolmanagerUpdatePoolSize(TQThreadPoolManager* self);
82#define tqthreadpoolmanagerUpdatePoolSize(self) (self)->_->updatePoolSize(TQThreadPoolManager(self))
83
#define saDeclarePtr(name)
Definition sarray.h:98
CX Object System - Object-oriented programming in C.