Loading...
Searching...
No Matches
DeferredOperationsManager.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4//
5// Created by Dave Smith on 12/16/25.
6//
7
8#ifndef MALENA_DEFERREDOPERATIONSMANAGER_H
9#define MALENA_DEFERREDOPERATIONSMANAGER_H
10
12#include <functional>
13#include <vector>
14
15namespace ml
16{
65 template<typename Derived>
67 {
68 protected:
70 inline static int busyDepth = 0;
71
73 inline static std::vector<std::function<void()>> pendingOperations;
74
82 static void beginBusy();
83
91 static void endBusy();
92
103 static void deferOrExecute(std::function<void()> operation);
104
105 public:
114 static bool isBusy();
115
126 static void processPending();
127
135 static void clearPending();
136 };
137
138} // namespace ml
139
140#include "../../../src/Core/DeferredOperationsManager.tpp"
141#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:22