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
@@ -49,6 +49,12 @@ public:
|
||||
// Optional (enables hot-reload state transfer):
|
||||
// void void_plugin_transfer_state(void* old, void* new)
|
||||
//
|
||||
// Optional (enables host-supplied configuration):
|
||||
// void void_plugin_configure(void* instance, const char* config)
|
||||
// — called by the host with an opaque configuration string (typically
|
||||
// JSON) after create and after each hot-reload swap, before
|
||||
// on_load(). The string is only valid for the duration of the call.
|
||||
//
|
||||
// Optional v2 state protocol (preferred over transfer_state when both
|
||||
// sides provide it; survives layout changes between plugin versions):
|
||||
//
|
||||
@@ -67,6 +73,7 @@ using create_fn = void* (*)(void);
|
||||
using destroy_fn = void (*)(void*);
|
||||
using info_fn = PluginInfo (*)(void);
|
||||
using transfer_fn = void (*)(void* old_instance, void* new_instance);
|
||||
using configure_fn = void (*)(void* instance, const char* config);
|
||||
using state_version_fn = std::uint32_t (*)(void);
|
||||
using serialize_fn = const char* (*)(void* instance);
|
||||
using free_string_fn = void (*)(const char*);
|
||||
@@ -77,6 +84,7 @@ inline constexpr const char* kCreateSymbol = "void_plugin_create";
|
||||
inline constexpr const char* kDestroySymbol = "void_plugin_destroy";
|
||||
inline constexpr const char* kInfoSymbol = "void_plugin_info";
|
||||
inline constexpr const char* kTransferSymbol = "void_plugin_transfer_state";
|
||||
inline constexpr const char* kConfigureSymbol = "void_plugin_configure";
|
||||
inline constexpr const char* kStateVersionSymbol = "void_plugin_state_version";
|
||||
inline constexpr const char* kSerializeSymbol = "void_plugin_serialize_state";
|
||||
inline constexpr const char* kFreeStringSymbol = "void_plugin_free_string";
|
||||
|
||||
Reference in new issue
Block a user