I am implementing a set of simple protocols using boost::asio (oblivious transfer schemes). These are CPU bound when they run. To improve efficiency, I want to try to keep both hosts working as much as possible. If host A has the choice between preforming two tasks, one of which would let host B start computation, and one which wouldn't, I want host A to pick the former.
Currently, io_service is running computationally intensive handlers before async_writes. Unless the tcp window is full (or some similar condition is blocking writing data to the socker), it's almost certainly better to finish the async_write rather than running some other handler.
I have seen asio's example of a priority queue for handlers. Is reimplementing async_write to use such a priority queue the only solution to my problem?
There's an example in the documentation describing how to attach a priority to completion handlers. You won't need to reimplement async_write
, just implement your own version of the handler_priority_queue
class from the example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With