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:
1 parent
da2e93c405
commit
28b94883fd
156 files changed
+278
-220
No files matched your search
@@ -0,0 +1,88 @@
|
||||
#include <Void/Async/ThreadPool.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
|
||||
using Void::Concurrency::ThreadPool;
|
||||
|
||||
Void::Testing::Test thread_count_matches_requested()
|
||||
{
|
||||
ThreadPool pool{4};
|
||||
Void::Testing::expect_eq(pool.thread_count(), std::size_t{4});
|
||||
}
|
||||
|
||||
Void::Testing::Test defaults_to_hardware_concurrency()
|
||||
{
|
||||
ThreadPool pool;
|
||||
Void::Testing::expect(pool.thread_count() >= 1);
|
||||
}
|
||||
|
||||
Void::Testing::Test submit_returns_correct_value()
|
||||
{
|
||||
ThreadPool pool{2};
|
||||
auto fut = pool.submit([] { return 42; });
|
||||
Void::Testing::expect_eq(fut.get(), 42);
|
||||
}
|
||||
|
||||
Void::Testing::Test tasks_run_concurrently()
|
||||
{
|
||||
constexpr int N = 8;
|
||||
ThreadPool pool{N};
|
||||
std::atomic<int> counter{0};
|
||||
std::vector<std::future<void>> futs;
|
||||
futs.reserve(N);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
futs.push_back(pool.submit([&] {
|
||||
++counter;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{5});
|
||||
}));
|
||||
}
|
||||
for (auto& f : futs) {
|
||||
f.get();
|
||||
}
|
||||
Void::Testing::expect_eq(counter.load(), N);
|
||||
}
|
||||
|
||||
Void::Testing::Test parallel_sum_is_correct()
|
||||
{
|
||||
ThreadPool pool{4};
|
||||
constexpr int N = 100;
|
||||
std::atomic<long long> total{0};
|
||||
std::vector<std::future<void>> futs;
|
||||
futs.reserve(N);
|
||||
for (int i = 1; i <= N; ++i) {
|
||||
futs.push_back(pool.submit([&, i] { total += i; }));
|
||||
}
|
||||
for (auto& f : futs) {
|
||||
f.get();
|
||||
}
|
||||
Void::Testing::expect_eq(total.load(), 5050LL);
|
||||
}
|
||||
|
||||
Void::Testing::Test exception_propagates_through_future()
|
||||
{
|
||||
ThreadPool pool{1};
|
||||
auto fut = pool.submit([] -> int { throw std::runtime_error("boom"); });
|
||||
bool caught = false;
|
||||
try {
|
||||
fut.get();
|
||||
} catch (const std::runtime_error& e) {
|
||||
caught = (std::string{e.what()} == "boom");
|
||||
}
|
||||
Void::Testing::expect(caught);
|
||||
}
|
||||
|
||||
Void::Testing::Test submit_after_destruction_throws()
|
||||
{
|
||||
std::optional<std::future<int>> fut;
|
||||
{
|
||||
ThreadPool pool{1};
|
||||
fut = pool.submit([] { return 1; });
|
||||
fut->get();
|
||||
}
|
||||
// pool is now destroyed; this just verifies destruction was clean
|
||||
Void::Testing::expect(true);
|
||||
}
|
||||
Reference in new issue
Block a user