
Christopher Kohlhoff wrote:
Hi Peter,
--- Peter Dimov <pdimov@mmltd.net> wrote:
Why is
http://asio.sourceforge.net/boost-asio-proposal-0.3.6/libs/asio/doc/tutorial...
using raw pointers, strdup, new, free and delete? This is soo 1996. Tutorials shoud teach.
Yep, this already came up in a review and I'm planning to change it. IIRC, the motivation for doing it this way was:
- to avoid introducing too many boost facilities at once
- to illustrate the "exactly-once" callback invocation
Can you explain the "exactly once" principle in more detail, or point me to the documentation that discusses it? boost::asio::socket_acceptor tcp_acceptor(demuxer, boost::asio::ipv4::tcp::endpoint(13)); boost::asio::stream_socket* tcp_socket = new boost::asio::stream_socket(demuxer); tcp_acceptor.async_accept(*tcp_socket, boost::bind(handle_tcp_accept, &tcp_acceptor, tcp_socket, boost::asio::placeholders::error)); For example, what happens here if async_accept fails, perhaps because of insufficient memory? Does it throw bad_alloc? Is the handler executed? http://asio.sourceforge.net/boost-asio-proposal-0.3.6/libs/asio/doc/design/d... could have answered my question since the boost::function<> constructor can throw and in this case tcp_socket would obviously leak, but I don't see this cited as an argument against function<> use?