TazGraph Project v0.1.0
Loading...
Searching...
No Matches
RenderCommandQueue.h
1#pragma once
2#include <vector>
3#include <mutex>
4#include <functional>
5
7 std::vector<std::function<void()>> commands;
8 std::mutex mutex;
9 std::condition_variable cv;
10 bool isReady = false;
11
12 void Submit(std::function<void()> cmd) {
13 std::lock_guard<std::mutex> lock(mutex);
14 commands.push_back(std::move(cmd));
15 isReady = true;
16 }
17
18 void Execute() {
19 std::lock_guard<std::mutex> lock(mutex);
20 for (auto& cmd : commands) cmd();
21 commands.clear();
22 cv.notify_all();
23 isReady = false;
24 }
25
26 void Wait() {
27 std::unique_lock<std::mutex> lock(mutex);
28 cv.wait(lock, [this]() {
29 return commands.empty();
30 });
31 }
32};
Definition RenderCommandQueue.h:6