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 <cx/struct.h>
7#include "tqmanager.h"
8#include <cx/taskqueue/worker/tqthreadworker.h>
9
10CX_C_BEGIN
11
12typedef struct TaskQueue TaskQueue;
13typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
14typedef struct TaskQueue TaskQueue;
15typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
16typedef struct TQThreadPoolRunner TQThreadPoolRunner;
17typedef struct TQThreadPoolRunner_WeakRef TQThreadPoolRunner_WeakRef;
18typedef struct TQThreadPoolManager TQThreadPoolManager;
19typedef struct TQThreadPoolManager_WeakRef TQThreadPoolManager_WeakRef;
20saDeclarePtr(TQThreadPoolManager);
21saDeclarePtr(TQThreadPoolManager_WeakRef);
22#define _sti_TQThreadPoolManager _sti_object
23#define SType_TQThreadPoolManager TQThreadPoolManager*
24#define STStorageType_TQThreadPoolManager TQThreadPoolManager*
25#define STypeArg_TQThreadPoolManager(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(TQThreadPoolManager, val))
26#define STypeArgPtr_TQThreadPoolManager(type, val) (stgeneric*)objInstCheckClassPtr(TQThreadPoolManager, val)
27#define STypeCheckedArg_TQThreadPoolManager(type, val) stType(type), stArg(type, val)
28#define STypeCheckedPtrArg_TQThreadPoolManager(type, val) stType(type), stArgPtr(type, val)
29
30typedef struct TQThreadPoolManager_ClassIf {
31 ObjIface* _implements;
32 ObjIface* _parent;
33 size_t _size;
34
35 bool (*start)(_In_ void* self, _In_ TaskQueue* tq);
36 bool (*stop)(_In_ void* self);
37 void (*notify)(_In_ void* self, bool wakeup);
38 // for in-worker managers, this is called BEFORE a task is run by the worker
39 void (*pretask)(_In_ void* self);
40 int64 (*tick)(_In_ void* self);
41 void (*updatePoolSize)(_In_ void* self);
42} TQThreadPoolManager_ClassIf;
43extern TQThreadPoolManager_ClassIf TQThreadPoolManager_ClassIf_tmpl;
44
45typedef struct TQThreadPoolManager {
46 union {
47 TQThreadPoolManager_ClassIf* _;
48 void* _is_TQThreadPoolManager;
49 void* _is_TQManager;
50 void* _is_ObjInst;
51 };
52 ObjClassInfo* _clsinfo;
53 atomic(uintptr) _ref;
54 atomic(ptr) _weakref;
55
56 TaskQueue* tq;
57 bool needsWorkerTick; // true if this manager needs to be ticked by the worker
58 TQThreadPoolRunner* runner;
59 uint32 lastcount;
60 int64 lastop;
61 int64 idlestart;
62} TQThreadPoolManager;
63extern ObjClassInfo TQThreadPoolManager_clsinfo;
64#define TQThreadPoolManager(inst) objInstCheckClass(TQThreadPoolManager, inst)
65#define TQThreadPoolManagerNone ((TQThreadPoolManager*)NULL)
66
67typedef struct TQThreadPoolManager_WeakRef {
68 union {
69 ObjInst* _inst;
70 void* _is_TQThreadPoolManager_WeakRef;
71 void* _is_TQManager_WeakRef;
72 void* _is_ObjInst_WeakRef;
73 };
74 atomic(uintptr) _ref;
75 RWLock _lock;
76} TQThreadPoolManager_WeakRef;
77#define TQThreadPoolManager_WeakRef(inst) objWeakRefCheckClass(TQThreadPoolManager, inst)
78
79// bool tqthreadpoolmanagerStart(TQThreadPoolManager* self, TaskQueue* tq);
80#define tqthreadpoolmanagerStart(self, tq) (self)->_->start(TQThreadPoolManager(self), TaskQueue(tq))
81// bool tqthreadpoolmanagerStop(TQThreadPoolManager* self);
82#define tqthreadpoolmanagerStop(self) (self)->_->stop(TQThreadPoolManager(self))
83// void tqthreadpoolmanagerNotify(TQThreadPoolManager* self, bool wakeup);
84#define tqthreadpoolmanagerNotify(self, wakeup) (self)->_->notify(TQThreadPoolManager(self), wakeup)
85// void tqthreadpoolmanagerPretask(TQThreadPoolManager* self);
86//
87// for in-worker managers, this is called BEFORE a task is run by the worker
88#define tqthreadpoolmanagerPretask(self) (self)->_->pretask(TQThreadPoolManager(self))
89// int64 tqthreadpoolmanagerTick(TQThreadPoolManager* self);
90#define tqthreadpoolmanagerTick(self) (self)->_->tick(TQThreadPoolManager(self))
91// void tqthreadpoolmanagerUpdatePoolSize(TQThreadPoolManager* self);
92#define tqthreadpoolmanagerUpdatePoolSize(self) (self)->_->updatePoolSize(TQThreadPoolManager(self))
93
94CX_C_END
#define saDeclarePtr(name)
Definition sarray.h:100
CX Struct System - Introspectable, serializable POD structures in C.
CX Object System - Object-oriented programming in C.