14 Oct
2015
14 Oct
'15
2:54 p.m.
Hartmut Kaiser wrote:
FWIW, the design decision to let those (and only those) futures block on destruction which are returned from async was one of the really bad decisions made for C++11, however that's just my opinion (others agree, but yet others disagree).
I agree completely. The correct thing to do would have been to introduce a separate class, I'll call it barrier here, although this is perhaps not ideal, which takes care of lifetime issues by blocking in its destructor, like this: X x; Y y; barrier b; auto f1 = async( b, [&]{ x.f( y, 1 ); } ); auto f2 = async( b, [&]{ x.f( y, 2 ); } );