c++ – How to use boost::asio with a custom reactor
I’m trying to integrate boost::asio with a third-party event_loop that will manage all my fds and timers etc in a manner that is similar to epoll. I’ve looked at the documentation as well as the existing reactors/services in boost such as the epoll_reactor and the io_uring_service and it’s not obvious to me how to tell boost::asio to use a different reactor/service at run-time (ie other than the default ones that are typedef’d at compile time in reactor.hpp). I have all the functionality I need to implement my own asio reactor with this third-party event-loop, I just can’t figure out how to plug it in using the boost::asio interface and hooks.
I see that is possible to create a custom service, using boost::asio::use_service() and the service registry, and I see that the epoll_reactor and io_uring_service both extend the execution_context_service_base interface but I can’t find any example that uses a custom reactor, or any kind of alternative event-loop implementation at run-time.
Please can someone point me to an example of how to integrate your own reactor service into boost::asio, or if this is not possible in the current design of boost::asio, can you suggest a clean way for me to include the io_context so that it has a different typedef for it’s default reactor type?
Read more here: Source link