boost::asio based scheduler #350
-
I am trying to implement a scheduler that can operate on Asio executors. So far I have used the Qt event loop scheduler as an example. In there, you dispatch on the Qt event loop utilizing a timer to get the function to execute in the eventloop's context. I would like to do the same, but with a specific executor and not a singleton as Qt's main event loop is. I think the runloop_scheduler is what I want to use, but it is not clear how I want to manage the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
About runloop_scheduler: it doesn't requires that runloop_scheduler should be static or something like this. It snake example it is global just for simplicity (prevent passing it as argument to each method). In general it works like this:
So, it is kind of "manual" scheduler: you decide when and how many schedulables you want to proceed at the specific moment. I'm not familiar with asio executors, but looks like you need to pass context/executor inside your new custom scheduler and pass it to required operator. Operator would call |
Beta Was this translation helpful? Give feedback.
About runloop_scheduler: it doesn't requires that runloop_scheduler should be static or something like this. It snake example it is global just for simplicity (prevent passing it as argument to each method). In general it works like this:
runloop_scheduler
. Scheduler owns shared_ptr to queue of schedulablesobserve_on
), then it just keeps copy of this oneobserver_on
callscreate_worker
during subscription for passed subscriber. At this moment we have separate and uniq worker for specific subscriber. This worker keeps weak_ptr to same queue as original scheduler