On Wed, Jul 22, 2009 at 4:04 PM, Steven Watanabe
AMDG
Zachary Turner wrote:
<snip>
void client::start_work() { apply_visitor( bind(do_work_visitor(), _1, protect(bind(&client::work_finished, this, _1, _2))) , work_variant_); } <snip>
template<class Handler> void async_do_work(Handler h) { //impl supports the same basic interface as worker
impl->async_do_work( bind(&worker::intercept_handler<Handler>, this, h, _1, _2)); }
Since h is a bind expression it needs to be protect'ed.
Yes I tried that as well but was not able to get it working. Anyway I never got it to work but I tried Emil's suggestion of using boost::function and that fixed the problem. I'm sure I was just doing something wrong, or perhaps dealing with compiler non-comformance issues, but the error messages are very difficult to diagnose sometimes, and will sometimes appear on functions that are not even the one causing the problem. In this case for example the error referred to the apply_visitor() line of code and there was no mention in the error logs of the line of code containing the bind inside of async_do_work, even though that was clearly where the problem was.