On 9/30/2013 5:41 PM, Quoth Bo Jensen:
I am calling it ala like this :
/* Create new tasks */
basistasks_[workerid] =
boost::make_shared<boost::packaged_task<BasisSelectRet>
>(boost::bind(&CallBasisSelection,&worker,boost::ref(io_error_[workerid])));
What is "worker" here? Could it become invalid before the join completes?
Also note that when passing it to a different thread it's safer to allow the shared_ptr to be copied rather than being passed by reference, although this probably isn't related to your current problem.
You probably shouldn't be catching exceptions here. packaged_task will do that for you anyway, and as it stands I think there's a slim chance of a broken_promise exception that will bypass this code, so you'd need to catch where you're accessing the futures anyway. (If your number of jobs is larger than your number of threads.)
/* Helper function */
BasisSelectRet CallBasisSelection(TreeWorker
*worker,
boost::shared_ptr<ExceptionTransfer> &error)
{
BasisSelectRet ret = BasisSelectRetOk;
try
{
worker->BasisSelection();
}
catch( ... )
{
error->SetException(boost::current_exception());
}
return ret;
}
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users