Restructure into umbrella modules (~55 -> 16 targets)

Headers move, CMake targets merge, C++ namespaces stay unchanged:
- Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant
- Functional: Pipeline, Either, Result, Retry
- Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval
- Math: +Matrix, Numeric, Random, Histogram
- Text: Str, Format, Tokenizer, Diff, Encoding, Semver
- Data: Json, Csv, Ini
- Async: Coro, Concurrency, EventBus, Observable
- Time: +Bench
- Log: Log facade + Logging framework (facade now header-only, breaking
  the Stacktrace<->Log link cycle the merge would have created)
- System: FileSystem + Process
- Configuration: +Argparse
- Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail

Module system fixes:
- OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no
  longer depends on the alphabetical discovery order of src/ subdirs
  (Testing -> Text would have been silently dropped).
- Every header-only module now has a tracked module.cmake; previously the
  empty src/<Name> marker dirs were untracked, so a fresh clone would have
  silently skipped those modules.
- VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT.

Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files
prefixed: ResultBasic etc.). Test count verified identical (831) before and
after. README/CLAUDE.md module tables updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Fable 5 committed 2026-06-12 18:50:02 +03:00
1 parent da2e93c405
commit 28b94883fd
156 files changed
+278 -220

No files matched your search

+111
View File
@@ -0,0 +1,111 @@
#pragma once
#include <Void/Log/Log.hpp>
#include <condition_variable>
#include <format>
#include <functional>
#include <future>
#include <memory>
#include <mutex>
#include <queue>
#include <stdexcept>
#include <thread>
#include <vector>
namespace Void::Concurrency
{
class ThreadPool
{
public:
explicit ThreadPool(
std::size_t n = std::thread::hardware_concurrency())
{
const std::size_t count = (n > 0) ? n : 1;
workers_.reserve(count);
for (std::size_t i = 0; i < count; ++i) {
workers_.emplace_back([this] { worker_loop(); });
}
Void::Log::log(
Void::Log::Level::Debug, "Concurrency",
std::format("ThreadPool: started with {} threads", count));
}
~ThreadPool()
{
Void::Log::log(Void::Log::Level::Debug, "Concurrency",
"ThreadPool: stopping");
{
std::unique_lock lock{mu_};
stop_ = true;
}
cv_.notify_all();
for (auto& w : workers_) {
w.join();
}
}
ThreadPool(const ThreadPool&) = delete;
ThreadPool& operator=(const ThreadPool&) = delete;
ThreadPool(ThreadPool&&) = delete;
ThreadPool& operator=(ThreadPool&&) = delete;
template <std::invocable F>
auto submit(F&& f) -> std::future<std::invoke_result_t<F>>
{
using R = std::invoke_result_t<F>;
auto task = std::make_shared<std::packaged_task<R()>>(
std::forward<F>(f));
auto fut = task->get_future();
{
std::unique_lock lock{mu_};
if (stop_) {
throw std::runtime_error(
"Void::Concurrency::ThreadPool: submit after "
"shutdown");
}
queue_.push([task] { (*task)(); });
}
cv_.notify_one();
return fut;
}
std::size_t thread_count() const noexcept
{
return workers_.size();
}
std::size_t pending_count() const
{
std::unique_lock lock{mu_};
return queue_.size();
}
private:
void worker_loop()
{
for (;;) {
std::function<void()> task;
{
std::unique_lock lock{mu_};
cv_.wait(lock,
[this] { return stop_ || !queue_.empty(); });
if (stop_ && queue_.empty()) {
return;
}
task = std::move(queue_.front());
queue_.pop();
}
task();
}
}
std::vector<std::thread> workers_;
std::queue<std::function<void()>> queue_;
mutable std::mutex mu_;
std::condition_variable cv_;
bool stop_{false};
};
} // namespace Void::Concurrency