Loading...
Searching...
No Matches
DeferredOperationsManager.h
Go to the documentation of this file.
1//
2// Created by Dave Smith on 12/16/25.
3//
4
5#ifndef MALENA_DEFERREDOPERATIONSMANAGER_H
6#define MALENA_DEFERREDOPERATIONSMANAGER_H
7
8#include <functional>
9#include <vector>
10
11namespace ml
12{
60 template<typename Derived>
66 {
67 protected:
69 inline static int busyDepth = 0;
70
72 inline static std::vector<std::function<void()>> pendingOperations;
73
81 static void beginBusy();
82
90 static void endBusy();
91
102 static void deferOrExecute(std::function<void()> operation);
103
104 public:
113 static bool isBusy();
114
125 static void processPending();
126
134 static void clearPending();
135 };
136
137} // namespace ml
138
139#include "../../../src/ECS/Core/DeferredOperationsManager.tpp"
140#endif // MALENA_DEFERREDOPERATIONSMANAGER_H
CRTP base that gives a manager safe deferred-operation support.
static void processPending()
Flush all pending operations immediately.
static std::vector< std::function< void()> > pendingOperations
Queue of operations pending until the current iteration completes.
static int busyDepth
Iteration nesting depth. Operations are deferred while this is > 0.
static bool isBusy()
Return true if the manager is currently iterating.
static void endBusy()
Signal that iteration has ended; flush pending operations.
static void deferOrExecute(std::function< void()> operation)
Execute operation now if safe, otherwise queue it.
static void beginBusy()
Signal that iteration has begun.
static void clearPending()
Discard all pending operations without executing them.
Definition Component.h:18