|
Boost Users : |
From: mikpol (mike.polyakov_at_[hidden])
Date: 2008-01-06 16:13:12
Hi,
I've been trying to understand the reasons to have asio_handler_invoke
function, and so far I am unable to understand why it is needed. It is used
to override invocation policy for a function-like object based on the
handler. boost::asio gives one example with using io_service::strand:
template<typename F>
void asio_handler_invoke(F fun, MyHandler* h)
{
h->strand.invoke(fun);
}
My question is why is it needed to make this function templatized on ANY
function object, and not just MyHandler? Why can't we just define
MyHandler::operator() in terms of strand like this:
struct MyHandler
{
io_service::strand strand.
void operator()() {
strand.invoke(boost::bind(&MyHandler::private_invoke, this));
}
void private_invoke() {
// do stuff...
}
}
Thanks for any help.
-- View this message in context: http://www.nabble.com/boost%3A%3Aasio---reason-for-asio_handler_invoke-tp14653663p14653663.html Sent from the Boost - Users mailing list archive at Nabble.com.
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