CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
trlifo.h
Go to the documentation of this file.
1
28
29#pragma once
30// This header file is auto-generated!
31// Do not make changes to this file or they will be overwritten.
32// clang-format off
33#include <cx/obj.h>
34#include <cx/struct.h>
35#include "taskresource.h"
36#include <cx/thread/mutex.h>
38
39CX_C_BEGIN
40
41typedef struct ComplexTask ComplexTask;
42typedef struct ComplexTask_WeakRef ComplexTask_WeakRef;
43typedef struct TaskQueue TaskQueue;
44typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
45typedef struct TQWorker TQWorker;
46typedef struct TQWorker_WeakRef TQWorker_WeakRef;
47typedef struct ComplexTask ComplexTask;
48typedef struct ComplexTask_WeakRef ComplexTask_WeakRef;
49typedef struct TRGate TRGate;
50typedef struct TRGate_WeakRef TRGate_WeakRef;
51typedef struct ComplexTaskQueue ComplexTaskQueue;
52typedef struct ComplexTaskQueue_WeakRef ComplexTaskQueue_WeakRef;
53typedef struct TaskControl TaskControl;
54typedef struct TRLifo TRLifo;
55typedef struct TRLifo_WeakRef TRLifo_WeakRef;
56saDeclarePtr(TRLifo);
57saDeclarePtr(TRLifo_WeakRef);
58#define _sti_TRLifo _sti_object
59#define SType_TRLifo TRLifo*
60#define STStorageType_TRLifo TRLifo*
61#define STypeArg_TRLifo(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(TRLifo, val))
62#define STypeArgPtr_TRLifo(type, val) (stgeneric*)objInstCheckClassPtr(TRLifo, val)
63#define STypeCheckedArg_TRLifo(type, val) stType(type), stArg(type, val)
64#define STypeCheckedPtrArg_TRLifo(type, val) stType(type), stArgPtr(type, val)
65
66typedef struct TRLifo_ClassIf {
67 ObjIface* _implements;
68 ObjIface* _parent;
69 size_t _size;
70
71 bool (*registerTask)(_In_ void* self, ComplexTask* task);
72 bool (*canAcquire)(_In_ void* self, ComplexTask* task);
73 bool (*tryAcquire)(_In_ void* self, ComplexTask* task);
74 void (*release)(_In_ void* self, ComplexTask* task);
75} TRLifo_ClassIf;
76extern TRLifo_ClassIf TRLifo_ClassIf_tmpl;
77
81typedef struct TRLifo {
82 union {
83 TRLifo_ClassIf* _;
84 void* _is_TRLifo;
85 void* _is_TaskResource;
86 void* _is_ObjInst;
87 };
88 ObjClassInfo* _clsinfo;
89 atomic(uintptr) _ref;
90 atomic(ptr) _weakref;
91
92 Mutex _lifomtx;
93 ComplexTask* cur;
94 sa_ComplexTask _lifo;
95} TRLifo;
96extern ObjClassInfo TRLifo_clsinfo;
97#define TRLifo(inst) objInstCheckClass(TRLifo, inst)
98#define TRLifoNone ((TRLifo*)NULL)
99
100typedef struct TRLifo_WeakRef {
101 union {
102 ObjInst* _inst;
103 void* _is_TRLifo_WeakRef;
104 void* _is_TaskResource_WeakRef;
105 void* _is_ObjInst_WeakRef;
106 };
107 atomic(uintptr) _ref;
108 RWLock _lock;
109} TRLifo_WeakRef;
110#define TRLifo_WeakRef(inst) objWeakRefCheckClass(TRLifo, inst)
111
112_objfactory_guaranteed TRLifo* TRLifo_create();
117#define trlifoCreate() TRLifo_create()
118
119// bool trlifoRegisterTask(TRLifo* self, ComplexTask* task);
120#define trlifoRegisterTask(self, task) (self)->_->registerTask(TRLifo(self), ComplexTask(task))
121// bool trlifoCanAcquire(TRLifo* self, ComplexTask* task);
122#define trlifoCanAcquire(self, task) (self)->_->canAcquire(TRLifo(self), ComplexTask(task))
123// bool trlifoTryAcquire(TRLifo* self, ComplexTask* task);
124#define trlifoTryAcquire(self, task) (self)->_->tryAcquire(TRLifo(self), ComplexTask(task))
125// void trlifoRelease(TRLifo* self, ComplexTask* task);
126#define trlifoRelease(self, task) (self)->_->release(TRLifo(self), ComplexTask(task))
127
128CX_C_END
Complex task with dependencies, scheduling, and resource management.
#define saDeclarePtr(name)
Definition sarray.h:100
#define _objfactory_guaranteed
Definition objimpl.h:106
CX Struct System - Introspectable, serializable POD structures in C.
Mutex synchronization primitive.
CX Object System - Object-oriented programming in C.
Complex task with dependencies, scheduling, and resource management.
Definition mutex.h:60
One-time event gate for task synchronization.
Abstract base class for shared resources.