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
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
namespace Void::Log
|
||||
{
|
||||
@@ -21,14 +24,41 @@ namespace Void::Log
|
||||
using Sink = std::function<void(
|
||||
Level level, std::string_view module, std::string_view message)>;
|
||||
|
||||
namespace Detail
|
||||
{
|
||||
struct SinkState {
|
||||
Sink sink;
|
||||
std::shared_mutex mutex;
|
||||
};
|
||||
|
||||
inline SinkState& sink_state()
|
||||
{
|
||||
static SinkState state;
|
||||
return state;
|
||||
}
|
||||
} // namespace Detail
|
||||
|
||||
/// Install the global sink. Any previously installed sink is replaced.
|
||||
/// Pass a default-constructed (empty) Sink to silence all output.
|
||||
/// Thread-safe: the new sink is visible to all threads after this returns.
|
||||
void set_sink(Sink sink);
|
||||
inline void set_sink(Sink sink)
|
||||
{
|
||||
auto& state = Detail::sink_state();
|
||||
std::unique_lock lock{state.mutex};
|
||||
state.sink = std::move(sink);
|
||||
}
|
||||
|
||||
/// Emit one log event through the global sink.
|
||||
/// No-op (zero allocation) if no sink is installed.
|
||||
/// Thread-safe with respect to set_sink() and concurrent log() calls.
|
||||
void log(Level level, std::string_view module, std::string_view message);
|
||||
inline void log(Level level, std::string_view module,
|
||||
std::string_view message)
|
||||
{
|
||||
auto& state = Detail::sink_state();
|
||||
std::shared_lock lock{state.mutex};
|
||||
if (state.sink) {
|
||||
state.sink(level, module, message);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Void::Log
|
||||
Reference in new issue
Block a user