Share asio::io_context with dll?

I have an application that imitates state of a vehicle and uses various plugins to transmit data. Each plugin is loaded dynamically and provides protocol-specific implementation for an interface to send the data. By specification each plugin may be operating concurrently and a sending method may be asynchronous.
I would like to be able to share asio::io_context or asio::thread_pool to utilize those resources allocated by the application (core). Each plugin would use asio::strand if needed. I really wouldn’t want plugins to spawn new threads.

To provide compiler independence the API for a plugin is in C, hence I can’t pass asio entities just like that.

Is it possible though to expose a context or a thread pool to a dynamically loaded dll which may be compiled with another toolchain?
Maybe via some kind of native handles?
Maybe I could wrap a custom executor?
I didn’t find any constructors in the reference which would use native handles, etc.

Source: Windows Questions C++

LEAVE A COMMENT