feat(service): immutable snapshots, owning ServiceHandle, DAG lifecycle, and ServicePlugin split

This commit is contained in:
faumaray committed 2026-11-26 16:03:31 +03:00
1 parent 6b3dededac
commit 1474a69ab1
12 files changed
+2167 -137

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
#include <Void/Service/Registry.hpp>
#include <Void/Service/Service.hpp>
#include <Void/Service/Types.hpp>
#include <memory>
#include <string_view>
namespace
{
struct ICounter {
virtual ~ICounter() = default;
virtual int value() const = 0;
};
struct Counter final : Void::Service::IManagedService, ICounter {
std::string_view service_name() const override { return "counter"; }
int value() const override { return 42; }
};
} // namespace
int main()
{
Void::Service::ServiceRegistry reg;
Void::Service::ProviderSet set;
set.add<ICounter>("counter", std::make_shared<Counter>());
auto ep = reg.start_and_publish(std::move(set));
if (!ep) {
return 1;
}
auto handle = reg.acquire<ICounter>();
if (!handle || (*handle)->value() != 42 || handle->generation() != *ep) {
return 2;
}
auto report = reg.close_and_join();
return report && !report->clean() ? 0 : 3; // handle still held until return
}