Дано<wait_all_until_error_source()>, может быть более разумным сделать<wait_all_...()>, который собираетвсеошибки вместо представления только первого:
template<typenameFn,typename...Fns>std::vector<typenamestd::result_of<Fn()>::type>wait_all_collect_errors(Fn&&function,Fns&&...functions){std::size_tcount(1+sizeof...(functions));typedeftypenamestd::result_of<Fn()>::typereturn_t;typedeftypenameboost::fibers::future<return_t>future_t;typedefstd::vector<return_t>vector_t;vector_tresults;results.reserve(count);exception_listexceptions("wait_all_collect_errors() exceptions");// get channelstd::shared_ptr<boost::fibers::unbounded_channel<future_t>>channel(wait_all_until_error_source(std::forward<Fn>(function),std::forward<Fns>(functions)...));// fill results and/or exceptions vectorsfuture_tfuture;while(boost::fibers::channel_op_status::success==channel->pop(future)){std::exception_ptrexp=future.get_exception_ptr();if(!exp){results.push_back(future.get());}else{exceptions.add(exp);}}// if there were any exceptions, throwif(exceptions.size()){throwexceptions;}// no exceptions: return vector to callerreturnresults;}
Статья wait_all, collecting all exceptions раздела Chapter 1. Fiber when_all functionality может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.