
--- Felipe Magno de Almeida <felipe.m.almeida@gmail.com> 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