mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-23 10:12:26 +00:00
refactor: dissolve console_helpers into util, platform, and minecraft
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
|
||||
#include "platform/C4JThread.h"
|
||||
|
||||
class ShutdownManager {
|
||||
public:
|
||||
enum EThreadId {
|
||||
eMainThread,
|
||||
eLeaderboardThread,
|
||||
eCommerceThread,
|
||||
ePostProcessThread,
|
||||
eRunUpdateThread,
|
||||
eRenderChunkUpdateThread,
|
||||
eServerThread,
|
||||
eStorageManagerThreads,
|
||||
eConnectionReadThreads,
|
||||
eConnectionWriteThreads,
|
||||
eEventQueueThreads,
|
||||
|
||||
eThreadIdCount
|
||||
};
|
||||
|
||||
static void Initialise();
|
||||
static void StartShutdown();
|
||||
static void MainThreadHandleShutdown();
|
||||
|
||||
static void HasStarted(EThreadId threadId);
|
||||
static void HasStarted(EThreadId threadId,
|
||||
C4JThread::EventArray* eventArray);
|
||||
static bool ShouldRun(EThreadId threadId);
|
||||
static void HasFinished(EThreadId threadId);
|
||||
|
||||
private:
|
||||
struct GroupState {
|
||||
std::size_t started = 0;
|
||||
std::size_t running = 0;
|
||||
};
|
||||
|
||||
struct State {
|
||||
std::mutex mutex;
|
||||
std::condition_variable condition;
|
||||
std::array<GroupState, eThreadIdCount> groups{};
|
||||
std::atomic<bool> shutdownRequested{false};
|
||||
};
|
||||
|
||||
static State& GetState();
|
||||
};
|
||||
Reference in New Issue
Block a user