samedi 27 octobre 2018

Using Boost.Asio, is it possible to add a handler which is executed once per iteration of the event loop if there are no IO events?

I am currently writing a simple server using Boost.Asio 1.68 and I am wondering if there is a way for me to add a handler that is executed when the event loop has no other work to do.

Currently I have this:

void completionHandler (boost::asio::io_context* ioCtx){
  // poll for some condition
  // if (condition) do some work;
  ioCtx->post(boost::bind(completionHandler, ioCtx));
}

//elsewhere
ioCtx->post(boost::bind(completionHandler, ioCtx));

However, this doesn't exactly match what I want to do.

Aucun commentaire:

Enregistrer un commentaire