Boost logo

Boost Users :

Subject: [Boost-users] [Boost.Asio] Suggestion to improve the docs
From: dariomt_at_[hidden]
Date: 2016-09-07 09:42:16


Hi,

In the Boost.Asio docs (and in the standalone Asio) the io_service docs has
a section "Stopping the io_service from running out of work" where it
explains "if the application requires that all operations and handlers be
allowed to finish normally, the work object may be explicitly destroyed"
and then shows some code using an std::auto_ptr<boost::asio::io_service::work>
which will keep the work object on the heap.

However, in the accepted answer to [1] the same behavior is accomplished
with a, IMHO, more elegant solution: with a
boost::optional<boost::asio::io_service::work>,
which, if I'm correct, will keep the work object on the stack. To destroy
the work object the optional is assigned to boost::none.

I'd suggest improving the docs with the boost::optional case, which
 - does not use "ugly" (and deprecated) auto_ptr
 - keeps the boost::asio::io_service::work object on the stack

Regards

[1]
http://stackoverflow.com/questions/15568100/confused-when-boostasioio-service-run-method-blocks-unblocks



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net