feat(service): immutable snapshots, owning ServiceHandle, DAG lifecycle, and ServicePlugin split
This commit is contained in:
1 parent
6b3dededac
commit
1474a69ab1
12 files changed
+2167
-137
No files matched your search
@@ -237,6 +237,21 @@ if(_has_storage)
|
||||
run_consumer(StorageOnly "${install_prefix}" "StorageOnly" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
has_modules(_has_service Service Core Functional Time Async LogState)
|
||||
if(_has_service)
|
||||
run_consumer(ServiceOnly "${install_prefix}" "ServiceOnly" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
has_modules(_has_service_plugin ServicePlugin Service Plugin Functional System Data LogState Text Time Async Core)
|
||||
if(_has_service_plugin)
|
||||
run_consumer(ServicePluginOnly "${install_prefix}" "ServicePluginOnly"
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
# Foundation consumer with Core-formatting bridge and zero external packages.
|
||||
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Memory Core)
|
||||
if(_has_foundation)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidServiceOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Service)
|
||||
|
||||
add_executable(void_service_only_consumer main.cpp)
|
||||
target_link_libraries(void_service_only_consumer PRIVATE Void::Service)
|
||||
target_compile_features(void_service_only_consumer PRIVATE cxx_std_26)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME ServiceOnlyConsumer COMMAND void_service_only_consumer)
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidServicePluginOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS ServicePlugin)
|
||||
|
||||
add_executable(void_service_plugin_only_consumer main.cpp)
|
||||
target_link_libraries(void_service_plugin_only_consumer PRIVATE Void::ServicePlugin)
|
||||
target_compile_features(void_service_plugin_only_consumer PRIVATE cxx_std_26)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME ServicePluginOnlyConsumer COMMAND void_service_plugin_only_consumer)
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <Void/Service/PluginService.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
Void::Plugin::PluginManager plugins;
|
||||
Void::Service::ServiceRegistry registry;
|
||||
Void::Service::PluginServiceBinding<Void::Service::IService> binding{
|
||||
plugins, registry, "missing"};
|
||||
auto direct = Void::Service::acquire_plugin_service<Void::Service::IService>(
|
||||
plugins, "missing");
|
||||
return !binding.bind() && !direct.has_value() ? 0 : 1;
|
||||
}
|
||||
Reference in new issue
Block a user