Plugin interface for self-contained, event-loop-driven plugin components.
RunablePluginInterface (note: intentional spelling) combines a MessageLoop with the Plugin system to allow dynamic plugins to carry their own event loop.
A plugin that inherits this interface runs in its own MessageLoop thread, started by async_run() after loading. The host calls on_init() to initialise the plugin and on_deinit() to clean up before unloading.
- Plugin implementation example
public:
}
}
};
Abstract plugin interface that provides its own MessageLoop event thread.
定义 runnable_plugin_interface.h:76
virtual void on_init()=0
Called by the host after the plugin's event loop has started.
virtual void on_deinit()=0
Called by the host before the plugin is unloaded.
#define VLINK_PLUGIN_DECLARE(ImplementType, VersionMajor, VersionMinor)
Declares a plugin creation and destruction interface.
定义 plugin.h:380
- Host usage
instance->on_init();
instance->on_deinit();
bool async_run()
Starts the message loop on a new background thread (non-blocking).
Type-safe dynamic plugin loader with version verification and lifecycle management.
定义 plugin.h:122
std::shared_ptr< T > load(const std::string &lib_name, uint16_t version_major, uint16_t version_minor, const std::string &dir_name="", const std::deque< std::string > &search_paths=default_search_path(), const std::string &function_name=VLINK_MACRO_STRING_GET(VLINK_PLUGIN_CREATE_FUNC_NAME))
Loads a plugin implementing interface T from a shared library.
定义 plugin.h:281