Plugin: discovery, unload, config entry, multi-observer reloads, state API
Host-side additions for applications embedding a plugin system: - PluginManager::load_directory(dir) loads every shared-library file in a directory (filename order) with per-file expected results. - PluginManager::unload(name) drops the registry entry; the instance dies with its last pinned handle (RCU semantics, as on reload). - Optional C entry void_plugin_configure(inst, config): fed from PluginManagerOptions::config_provider after create and after each reload swap, before on_load(). - on_reloaded() is now multi-observer: returns a ReloadCallbackId, remove_on_reloaded() unregisters. Manual reload() now notifies observers too (previously only watched reloads did, contradicting the documented contract). PluginServiceBinding deregisters its callback on destruction (was a dangling-callback hazard). - PluginManager::serialize_state/deserialize_state expose the plugin's v2 state exports so an embedder can carry plugin state through its own hot reload. - ServiceRegistry::remove<I>() withdraws a provided service (child removal re-exposes a parent's entry). - EventBus::subscribe_scoped<E>() returns a move-only RAII Subscription that unsubscribes on destruction. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018yj92cCihyaYtf4gKCT3nv
This commit is contained in:
1 parent
7ca0e1b62e
commit
ee4486e1d2
15 files changed
+750
-24
No files matched your search
@@ -98,6 +98,18 @@ if(TARGET Void::Plugin)
|
||||
add_dependencies(VoidTests VoidTestPlugin)
|
||||
endif()
|
||||
|
||||
# Configurable plugin — exercises the optional void_plugin_configure
|
||||
# entry point driven by PluginManagerOptions::config_provider.
|
||||
add_library(VoidConfigurablePlugin SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins/ConfigurablePlugin.cpp")
|
||||
target_link_libraries(VoidConfigurablePlugin PRIVATE Void::Plugin)
|
||||
target_include_directories(VoidConfigurablePlugin PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins")
|
||||
target_compile_definitions(VoidTests PRIVATE
|
||||
"VOID_CONFIGURABLE_PATH=\"$<TARGET_FILE:VoidConfigurablePlugin>\""
|
||||
)
|
||||
add_dependencies(VoidTests VoidConfigurablePlugin)
|
||||
|
||||
# Stateful plugins (schema v1 + v2) for hot-reload/state-migration
|
||||
# tests. Same plugin name; v2 adds a field and migrates v1 JSON.
|
||||
add_library(VoidStatefulPluginV1 SHARED
|
||||
|
||||
Reference in new issue
Block a user