2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-02-11 01:53:02 +00:00

feat: add bind for loading fastfiles to ModMan

This commit is contained in:
Jan Laupetin
2025-10-11 12:51:21 +01:00
parent 42473a7320
commit 4911cfa4c6
15 changed files with 215 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
#pragma once
#include <condition_variable>
#include <deque>
#include <functional>
#include <mutex>
#include <optional>
#include <thread>
class DispatchableThread
{
public:
using cb_t = std::function<void()>;
DispatchableThread();
~DispatchableThread();
DispatchableThread(const DispatchableThread& other) = delete;
DispatchableThread(DispatchableThread&& other) noexcept = default;
DispatchableThread& operator=(const DispatchableThread& other) = delete;
DispatchableThread& operator=(DispatchableThread&& other) noexcept = default;
void Start();
void Terminate();
void Dispatch(cb_t cb);
private:
std::optional<cb_t> NextCallback();
void ThreadLoop();
std::mutex m_cb_mutex;
std::deque<cb_t> m_cb_list;
std::condition_variable m_cv;
std::thread m_thread;
bool m_terminate;
};