CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
tqmdedicated.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 "tqmthreadpool.h"
8
9CX_C_BEGIN
10
11typedef struct TaskQueue TaskQueue;
12typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
13typedef struct TaskQueue TaskQueue;
14typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
15typedef struct TQThreadPoolRunner TQThreadPoolRunner;
16typedef struct TQThreadPoolRunner_WeakRef TQThreadPoolRunner_WeakRef;
17typedef struct TQDedicatedManager TQDedicatedManager;
18typedef struct TQDedicatedManager_WeakRef TQDedicatedManager_WeakRef;
19saDeclarePtr(TQDedicatedManager);
20saDeclarePtr(TQDedicatedManager_WeakRef);
21#define _sti_TQDedicatedManager _sti_object
22#define SType_TQDedicatedManager TQDedicatedManager*
23#define STStorageType_TQDedicatedManager TQDedicatedManager*
24#define STypeArg_TQDedicatedManager(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(TQDedicatedManager, val))
25#define STypeArgPtr_TQDedicatedManager(type, val) (stgeneric*)objInstCheckClassPtr(TQDedicatedManager, val)
26#define STypeCheckedArg_TQDedicatedManager(type, val) stType(type), stArg(type, val)
27#define STypeCheckedPtrArg_TQDedicatedManager(type, val) stType(type), stArgPtr(type, val)
28
29typedef struct TQDedicatedManager_ClassIf {
30 ObjIface* _implements;
31 ObjIface* _parent;
32 size_t _size;
33
34 bool (*start)(_In_ void* self, _In_ TaskQueue* tq);
35 bool (*stop)(_In_ void* self);
36 void (*notify)(_In_ void* self, bool wakeup);
37 // for in-worker managers, this is called BEFORE a task is run by the worker
38 void (*pretask)(_In_ void* self);
39 int64 (*tick)(_In_ void* self);
40 void (*updatePoolSize)(_In_ void* self);
41} TQDedicatedManager_ClassIf;
42extern TQDedicatedManager_ClassIf TQDedicatedManager_ClassIf_tmpl;
43
44typedef struct TQDedicatedManager {
45 union {
46 TQDedicatedManager_ClassIf* _;
47 void* _is_TQDedicatedManager;
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 Thread* mgrthread;
63 Event mgrnotify;
64} TQDedicatedManager;
65extern ObjClassInfo TQDedicatedManager_clsinfo;
66#define TQDedicatedManager(inst) objInstCheckClass(TQDedicatedManager, inst)
67#define TQDedicatedManagerNone ((TQDedicatedManager*)NULL)
68
69typedef struct TQDedicatedManager_WeakRef {
70 union {
71 ObjInst* _inst;
72 void* _is_TQDedicatedManager_WeakRef;
73 void* _is_TQThreadPoolManager_WeakRef;
74 void* _is_TQManager_WeakRef;
75 void* _is_ObjInst_WeakRef;
76 };
77 atomic(uintptr) _ref;
78 RWLock _lock;
79} TQDedicatedManager_WeakRef;
80#define TQDedicatedManager_WeakRef(inst) objWeakRefCheckClass(TQDedicatedManager, inst)
81
82_objfactory_guaranteed TQDedicatedManager* TQDedicatedManager_create();
83// TQDedicatedManager* tqdedicatedmanagerCreate();
84#define tqdedicatedmanagerCreate() TQDedicatedManager_create()
85
86// bool tqdedicatedmanagerStart(TQDedicatedManager* self, TaskQueue* tq);
87#define tqdedicatedmanagerStart(self, tq) (self)->_->start(TQDedicatedManager(self), TaskQueue(tq))
88// bool tqdedicatedmanagerStop(TQDedicatedManager* self);
89#define tqdedicatedmanagerStop(self) (self)->_->stop(TQDedicatedManager(self))
90// void tqdedicatedmanagerNotify(TQDedicatedManager* self, bool wakeup);
91#define tqdedicatedmanagerNotify(self, wakeup) (self)->_->notify(TQDedicatedManager(self), wakeup)
92// void tqdedicatedmanagerPretask(TQDedicatedManager* self);
93//
94// for in-worker managers, this is called BEFORE a task is run by the worker
95#define tqdedicatedmanagerPretask(self) (self)->_->pretask(TQDedicatedManager(self))
96// int64 tqdedicatedmanagerTick(TQDedicatedManager* self);
97#define tqdedicatedmanagerTick(self) (self)->_->tick(TQDedicatedManager(self))
98// void tqdedicatedmanagerUpdatePoolSize(TQDedicatedManager* self);
99#define tqdedicatedmanagerUpdatePoolSize(self) (self)->_->updatePoolSize(TQDedicatedManager(self))
100
101CX_C_END
#define saDeclarePtr(name)
Definition sarray.h:100
#define _objfactory_guaranteed
Definition objimpl.h:106
CX Struct System - Introspectable, serializable POD structures in C.
CX Object System - Object-oriented programming in C.
Definition event.h:53