For some parallel programs, I could use the Java concept of CountDownLatch . Is there an equivalent for C ++ 11 or what would this concept be called in C ++?
I want to call a function after the count reaches zero.
If not already, I would write myself a class like the following:
class countdown_function { public: countdown_function( size_t count ); countdown_function( const countdown_function& ) = default; countdown_function( countdown_function&& ) = default; countdown_function& operator=( const countdown_function& ) = default; countdown_function& operator=( countdown_function&& ) = default;
Is something like this already available anywhere?
Scenario:
countdown_function counter( 2 ); counter = [success_callback]() { success_callback(); }; startTask1Async( [counter, somework]() { somework(); --counter; }, errorCallback ); startTask2Async( [counter, otherwork]() { otherwork(); --counter; }, errorCallback );
source share