Using io_service::poll
instead of io_service::run
is perfectly acceptable. The difference is explained in the documentation
The poll() function may also be used
to dispatch ready handlers, but
without blocking.
Note that io_service::run
will block if there’s any work
left in the queue
The work class is used to inform the
io_service when work starts and
finishes. This ensures that the
io_service object’s run() function
will not exit while work is underway,
and that it does exit when there is no
unfinished work remaining.
whereas io_service::poll
does not exhibit this behavior, it just invokes ready handlers. Also note that you will need to invoke io_service::reset on any subsequent invocation to io_service:run
or io_service::poll
.