CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
tqworker.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>
7
8typedef struct TaskQueue TaskQueue;
9typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
10typedef struct TQWorker TQWorker;
11typedef struct TQWorker_WeakRef TQWorker_WeakRef;
12saDeclarePtr(TQWorker);
13saDeclarePtr(TQWorker_WeakRef);
14
15typedef struct TQWorker_ClassIf {
16 ObjIface* _implements;
17 ObjIface* _parent;
18 size_t _size;
19
20 // hooks for derived classes to override if desired
21 // worker is starting up
22 void (*onStart)(_In_ void* self, _In_ TaskQueue* tq);
23 // worker should process tasks (call parent!)
24 int64 (*tick)(_In_ void* self, _In_ TaskQueue* tq);
25 // worker is shutting down
26 void (*onStop)(_In_ void* self, _In_ TaskQueue* tq);
27} TQWorker_ClassIf;
28extern TQWorker_ClassIf TQWorker_ClassIf_tmpl;
29
30typedef struct TQWorker {
31 union {
32 TQWorker_ClassIf* _;
33 void* _is_TQWorker;
34 void* _is_ObjInst;
35 };
36 ObjClassInfo* _clsinfo;
37 atomic(uintptr) _ref;
38 atomic(ptr) _weakref;
39
40} TQWorker;
41extern ObjClassInfo TQWorker_clsinfo;
42#define TQWorker(inst) ((TQWorker*)(unused_noeval((inst) && &((inst)->_is_TQWorker)), (inst)))
43#define TQWorkerNone ((TQWorker*)NULL)
44
45typedef struct TQWorker_WeakRef {
46 union {
47 ObjInst* _inst;
48 void* _is_TQWorker_WeakRef;
49 void* _is_ObjInst_WeakRef;
50 };
51 atomic(uintptr) _ref;
52 RWLock _lock;
53} TQWorker_WeakRef;
54#define TQWorker_WeakRef(inst) ((TQWorker_WeakRef*)(unused_noeval((inst) && &((inst)->_is_TQWorker_WeakRef)), (inst)))
55
56// void tqworkerOnStart(TQWorker* self, TaskQueue* tq);
57//
58// hooks for derived classes to override if desired
59// worker is starting up
60#define tqworkerOnStart(self, tq) (self)->_->onStart(TQWorker(self), TaskQueue(tq))
61// int64 tqworkerTick(TQWorker* self, TaskQueue* tq);
62//
63// worker should process tasks (call parent!)
64#define tqworkerTick(self, tq) (self)->_->tick(TQWorker(self), TaskQueue(tq))
65// void tqworkerOnStop(TQWorker* self, TaskQueue* tq);
66//
67// worker is shutting down
68#define tqworkerOnStop(self, tq) (self)->_->onStop(TQWorker(self), TaskQueue(tq))
69
#define saDeclarePtr(name)
Definition sarray.h:98
CX Object System - Object-oriented programming in C.
Shared types and configuration structures for the task queue system.