$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-12 18:58:10
--- Felipe Magno de Almeida <felipe.m.almeida_at_[hidden]> wrote:
<snip>
> You think every functor should be executed exactly-once for correct
> program design?
> Wouldnt this still be safe?
>
> class handler
> {
> void fail(asio::error err)
> {
> // handle the error case, and probably delete this handle, or
> reuse it for retrying
> }
>
> void success(int size)
> {
> // do something, or continue reading or delete this
> }
> // member variables
>
> public:
> handler()
> {
> async_read(s, buffers,
> combine_handlers(
> boost::bind(boost::mem_fn(&handler::success), this)
> , boost::bind(boost::mem_fn(&handler::fail), this)
> ));
> }
> };
Of course, you're right, and there's nothing unsafe with the above.
Somehow I had the idea that you wanted to share the same error handler
between multiple asynchronous operations as the default behaviour.
Cheers,
CHris