I am trying to understand the difference between io_service’s poll()/poll_one() and run()/run_one(). The difference as stated in the documentation is that poll() executes ready handlers as opposed to run() which executes any handler.
But nowhere in the boost documentation could I find the definition of a ‘ready handler’.
A valid answer to this question is one able to show, preferably with a code example, the difference between a ready and non-ready handler and the difference between how poll() and run() executes it.
Thanks.
If you use
io_service.poll_one();you will most likely not see any output because the timer has not elapsed yet.ready handlersimply means a handle that is ready to run (such as when a timer elapses or an operation finishes, etc.). However, if you useio_service.run_one();this call will block until the timer finishes and execute the handler.