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 "taskresource.h"
35#include <cx/thread/mutex.h>
37
38typedef struct ComplexTask ComplexTask;
39typedef struct ComplexTask_WeakRef ComplexTask_WeakRef;
40typedef struct TaskQueue TaskQueue;
41typedef struct TaskQueue_WeakRef TaskQueue_WeakRef;
42typedef struct TQWorker TQWorker;
43typedef struct TQWorker_WeakRef TQWorker_WeakRef;
44typedef struct ComplexTask ComplexTask;
45typedef struct ComplexTask_WeakRef ComplexTask_WeakRef;
46typedef struct TRGate TRGate;
47typedef struct TRGate_WeakRef TRGate_WeakRef;
48typedef struct ComplexTaskQueue ComplexTaskQueue;
49typedef struct ComplexTaskQueue_WeakRef ComplexTaskQueue_WeakRef;
50typedef struct TaskControl TaskControl;
51typedef struct TRLifo TRLifo;
52typedef struct TRLifo_WeakRef TRLifo_WeakRef;
53saDeclarePtr(TRLifo);
54saDeclarePtr(TRLifo_WeakRef);
55
56typedef struct TRLifo_ClassIf {
57 ObjIface* _implements;
58 ObjIface* _parent;
59 size_t _size;
60
61 bool (*registerTask)(_In_ void* self, ComplexTask* task);
62 bool (*canAcquire)(_In_ void* self, ComplexTask* task);
63 bool (*tryAcquire)(_In_ void* self, ComplexTask* task);
64 void (*release)(_In_ void* self, ComplexTask* task);
65} TRLifo_ClassIf;
66extern TRLifo_ClassIf TRLifo_ClassIf_tmpl;
67
71typedef struct TRLifo {
72 union {
73 TRLifo_ClassIf* _;
74 void* _is_TRLifo;
75 void* _is_TaskResource;
76 void* _is_ObjInst;
77 };
78 ObjClassInfo* _clsinfo;
79 atomic(uintptr) _ref;
80 atomic(ptr) _weakref;
81
82 Mutex _lifomtx;
83 ComplexTask* cur;
84 sa_ComplexTask _lifo;
85} TRLifo;
86extern ObjClassInfo TRLifo_clsinfo;
87#define TRLifo(inst) ((TRLifo*)(unused_noeval((inst) && &((inst)->_is_TRLifo)), (inst)))
88#define TRLifoNone ((TRLifo*)NULL)
89
90typedef struct TRLifo_WeakRef {
91 union {
92 ObjInst* _inst;
93 void* _is_TRLifo_WeakRef;
94 void* _is_TaskResource_WeakRef;
95 void* _is_ObjInst_WeakRef;
96 };
97 atomic(uintptr) _ref;
98 RWLock _lock;
99} TRLifo_WeakRef;
100#define TRLifo_WeakRef(inst) ((TRLifo_WeakRef*)(unused_noeval((inst) && &((inst)->_is_TRLifo_WeakRef)), (inst)))
101
102_objfactory_guaranteed TRLifo* TRLifo_create();
107#define trlifoCreate() TRLifo_create()
108
109// bool trlifoRegisterTask(TRLifo* self, ComplexTask* task);
110#define trlifoRegisterTask(self, task) (self)->_->registerTask(TRLifo(self), ComplexTask(task))
111// bool trlifoCanAcquire(TRLifo* self, ComplexTask* task);
112#define trlifoCanAcquire(self, task) (self)->_->canAcquire(TRLifo(self), ComplexTask(task))
113// bool trlifoTryAcquire(TRLifo* self, ComplexTask* task);
114#define trlifoTryAcquire(self, task) (self)->_->tryAcquire(TRLifo(self), ComplexTask(task))
115// void trlifoRelease(TRLifo* self, ComplexTask* task);
116#define trlifoRelease(self, task) (self)->_->release(TRLifo(self), ComplexTask(task))
117
Complex task with dependencies, scheduling, and resource management.
#define saDeclarePtr(name)
Definition sarray.h:98
#define _objfactory_guaranteed
Definition objimpl.h:104
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.