CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
trfifo.h
Go to the documentation of this file.
1
27
28#pragma once
29// This header file is auto-generated!
30// Do not make changes to this file or they will be overwritten.
31// clang-format off
32#include <cx/obj.h>
33#include "taskresource.h"
34#include <cx/thread/mutex.h>
35
36typedef struct ComplexTask ComplexTask;
37typedef struct ComplexTask_WeakRef ComplexTask_WeakRef;
38typedef struct ComplexTask ComplexTask;
39typedef struct ComplexTask_WeakRef ComplexTask_WeakRef;
40typedef struct TRFifoNode TRFifoNode;
41typedef struct TRFifo TRFifo;
42typedef struct TRFifo_WeakRef TRFifo_WeakRef;
44saDeclarePtr(TRFifo_WeakRef);
45
49
50typedef struct TRFifoNode {
51 TRFifoNode *next;
52 ComplexTask *task;
53} TRFifoNode;
54
55typedef struct TRFifo_ClassIf {
56 ObjIface* _implements;
57 ObjIface* _parent;
58 size_t _size;
59
60 bool (*registerTask)(_In_ void* self, ComplexTask* task);
61 bool (*canAcquire)(_In_ void* self, ComplexTask* task);
62 bool (*tryAcquire)(_In_ void* self, ComplexTask* task);
63 void (*release)(_In_ void* self, ComplexTask* task);
64} TRFifo_ClassIf;
65extern TRFifo_ClassIf TRFifo_ClassIf_tmpl;
66
68typedef struct TRFifo {
69 union {
70 TRFifo_ClassIf* _;
71 void* _is_TRFifo;
72 void* _is_TaskResource;
73 void* _is_ObjInst;
74 };
75 ObjClassInfo* _clsinfo;
76 atomic(uintptr) _ref;
77 atomic(ptr) _weakref;
78
79 Mutex _fifomtx;
81 TRFifoNode* head;
82 TRFifoNode* tail;
83} TRFifo;
84extern ObjClassInfo TRFifo_clsinfo;
85#define TRFifo(inst) ((TRFifo*)(unused_noeval((inst) && &((inst)->_is_TRFifo)), (inst)))
86#define TRFifoNone ((TRFifo*)NULL)
87
88typedef struct TRFifo_WeakRef {
89 union {
90 ObjInst* _inst;
91 void* _is_TRFifo_WeakRef;
92 void* _is_TaskResource_WeakRef;
93 void* _is_ObjInst_WeakRef;
94 };
95 atomic(uintptr) _ref;
96 RWLock _lock;
97} TRFifo_WeakRef;
98#define TRFifo_WeakRef(inst) ((TRFifo_WeakRef*)(unused_noeval((inst) && &((inst)->_is_TRFifo_WeakRef)), (inst)))
99
100_objfactory_guaranteed TRFifo* TRFifo_create();
105#define trfifoCreate() TRFifo_create()
106
107// bool trfifoRegisterTask(TRFifo* self, ComplexTask* task);
108#define trfifoRegisterTask(self, task) (self)->_->registerTask(TRFifo(self), ComplexTask(task))
109// bool trfifoCanAcquire(TRFifo* self, ComplexTask* task);
110#define trfifoCanAcquire(self, task) (self)->_->canAcquire(TRFifo(self), ComplexTask(task))
111// bool trfifoTryAcquire(TRFifo* self, ComplexTask* task);
112#define trfifoTryAcquire(self, task) (self)->_->tryAcquire(TRFifo(self), ComplexTask(task))
113// void trfifoRelease(TRFifo* self, ComplexTask* task);
114#define trfifoRelease(self, task) (self)->_->release(TRFifo(self), ComplexTask(task))
115
#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
Strictly ordered FIFO resource for serialized task execution.
Definition trfifo.h:68
TRFifoNode * head
Head of wait queue.
Definition trfifo.h:81
TRFifoNode * tail
Tail of wait queue.
Definition trfifo.h:82
ComplexTask * cur
Currently running task.
Definition trfifo.h:80
Abstract base class for shared resources.