Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-02-07 14:53:35


Christopher Kohlhoff wrote:
> Hi Peter,
>
> --- Peter Dimov <pdimov_at_[hidden]> wrote:
>
>> Why is
>>
>>
> http://asio.sourceforge.net/boost-asio-proposal-0.3.6/libs/asio/doc/tutorial/tutdaytime7.html
>>
>> 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/designhandlers.html

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?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk