Add async/resilience/reflection primitives + FSM v2 rewrite
A round of new universal capabilities (all generic — templated/reflection based, no app coupling), verified by the test suite (1103 passing): Data reflection: - Reflect.hpp now (de)serializes chrono::duration, chrono::time_point, std::variant (tagged), std::array, and non-string-keyed std::map; Meta.hpp gains is_time_point_v et al. Async: - EventBus gains Mode::Async (worker-thread dispatch + flush()). - ThreadPool gains a bounded queue, try_submit(), and rejection stats. New modules / containers: - Resilience: TokenBucket, KeyedRateLimiter<Key>, CircuitBreaker, ResourceMonitor. - Containers: BufferPool<T> (size-class buffer reuse) and Cache<K,V> (per-entry TTL, LRU/LFU/FIFO eviction, hit/miss stats). - System: process/CPU/memory metrics (Metrics.hpp) and a streaming Process API. Plus FSM v2 (typed Success/Failure, sub-machines, parallel regions, history states, deferred events), Configuration/Logging reflection helpers, and the accompanying test suites. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
43b5a81504
commit
80293ee56f
93 files changed
+8500
-3312
No files matched your search
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Core/Meta.hpp>
|
||||
|
||||
#include <concepts>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#if __has_include(<meta>)
|
||||
#include <meta>
|
||||
#define VOID_MOCK_HAS_REFLECTION 1
|
||||
#endif
|
||||
|
||||
// ── Reflection helpers for mocking
|
||||
// ──────────────────────────────────────────── This toolchain's P2996 has rich
|
||||
// introspection + define_aggregate (it can even generate a MockFunction<Sig>
|
||||
// data member per interface virtual), but it has NO code injection, so the
|
||||
// virtual *override functions* a full auto-mock needs cannot be synthesized.
|
||||
// These helpers therefore cover the achievable ground: list an interface's
|
||||
// virtual methods and statically check a hand-written mock implements all of
|
||||
// them.
|
||||
|
||||
namespace Void::TestingMock
|
||||
{
|
||||
|
||||
#ifdef VOID_MOCK_HAS_REFLECTION
|
||||
|
||||
namespace meta = std::meta;
|
||||
|
||||
/// The identifiers of every virtual member function of interface `I`
|
||||
/// (excluding the destructor), in declaration order.
|
||||
template <typename I> [[nodiscard]] std::vector<std::string> method_names()
|
||||
{
|
||||
std::vector<std::string> out;
|
||||
template for (constexpr auto m :
|
||||
std::define_static_array(meta::members_of(
|
||||
^^I, meta::access_context::unchecked())))
|
||||
{
|
||||
if constexpr (meta::is_function(m) && meta::is_virtual(m) &&
|
||||
!meta::is_destructor(m)) {
|
||||
out.emplace_back(meta::identifier_of(m));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Number of virtual methods (excluding the destructor) on `I`.
|
||||
template <typename I> [[nodiscard]] consteval std::size_t method_count()
|
||||
{
|
||||
std::size_t n = 0;
|
||||
template for (constexpr auto m :
|
||||
std::define_static_array(meta::members_of(
|
||||
^^I, meta::access_context::unchecked())))
|
||||
{
|
||||
if constexpr (meta::is_function(m) && meta::is_virtual(m) &&
|
||||
!meta::is_destructor(m)) {
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/// True if `Mock` is a complete, instantiable implementation of interface
|
||||
/// `I` — i.e. it derives `I` and overrides every pure-virtual method (so no
|
||||
/// abstract methods remain). A compile-time completeness check:
|
||||
/// static_assert(TestingMock::covers<MockDb, IDatabase>());
|
||||
template <typename Mock, typename I> [[nodiscard]] consteval bool covers()
|
||||
{
|
||||
return std::derived_from<Mock, I> && !std::is_abstract_v<Mock>;
|
||||
}
|
||||
|
||||
#endif // VOID_MOCK_HAS_REFLECTION
|
||||
|
||||
} // namespace Void::TestingMock
|
||||
Reference in new issue
Block a user