Phase C: replace CommandManager's hand-rolled pool with Void ThreadPool

CommandManager dispatched async commands through a bespoke pool — a jthread
vector, a CommandTask queue, a mutex/condition_variable, and a manual
drain-on-shutdown loop. Replace it with a Void::Concurrency::ThreadPool:

- startThreadPool() builds the pool at THREAD_POOL_SIZE; shutdown() flips
  the accept flag and resets the pool (~ThreadPool drains queued commands
  then joins — the same shutdown semantics the manual loop had).
- dispatch() submits the CommandTask lambda straight to the pool instead of
  enqueuing + notifying; executeCommandAsync already swallows exceptions, so
  the discarded future is safe.
- processCommandQueue() and the queue/cv/worker members are gone.

Build green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-23 03:12:10 +03:00
1 parent da708fa9bb
commit ef094c0d78
2 files changed
+17 -52

No files matched your search

+5 -5
View File
@@ -4,7 +4,9 @@
#include <ConfigTypes.hpp>
#include <PluginTypes.hpp>
#include <Types.hpp>
#include <Void/Async/ThreadPool.hpp>
#include <atomic>
#include <memory>
#include <condition_variable>
#include <functional>
#include <future>
@@ -174,13 +176,11 @@ namespace Echoion::Core
};
void startThreadPool();
void processCommandQueue();
void executeCommandAsync(CommandTask task);
std::vector<std::jthread> workerThreads_;
std::queue<CommandTask> commandQueue_;
std::mutex queueMutex_;
std::condition_variable queueCv_;
// Void worker pool backing async command execution (drains
// in-flight commands on shutdown via ~ThreadPool).
std::unique_ptr<Void::Concurrency::ThreadPool> pool_;
std::atomic<bool> shutdown_{false};
static constexpr size_t THREAD_POOL_SIZE =
4; // Handle up to 4 concurrent commands