YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
yaclib::WaitGroup< Event > Class Template Referencefinal

An object that allows you to Add some amount of async operations and then Wait for it to be Done. More...

#include <wait_group.hpp>

Public Member Functions

 WaitGroup (std::size_t count=0) noexcept
 
YACLIB_INLINE void Add (std::size_t count=1) noexcept
 Add some amount of async operations.
 
YACLIB_INLINE void Done (std::size_t count=1) noexcept
 Done some Add-ed async operations.
 
template<bool NeedAdd = true, typename... V, typename... E>
YACLIB_INLINE void Consume (FutureBase< V, E > &&... futures) noexcept
 Consume Future by WaitGroup with auto Done.
 
template<bool NeedAdd = true, typename It >
YACLIB_INLINE std::enable_if_t<!is_future_base_v< It >, voidConsume (It begin, It end) noexcept
 Consume Future by WaitGroup with auto Done.
 
template<bool NeedAdd = true, typename It >
YACLIB_INLINE void Consume (It begin, std::size_t count) noexcept
 Consume Future by WaitGroup with auto Done.
 
template<bool NeedAdd = true, typename... V, typename... E>
YACLIB_INLINE void Attach (FutureBase< V, E > &... futures) noexcept
 Attach Future to WaitGroup with auto Done.
 
template<bool NeedAdd = true, typename It >
YACLIB_INLINE std::enable_if_t<!is_future_base_v< It >, voidAttach (It begin, It end) noexcept
 Attach Future to WaitGroup with auto Done.
 
template<bool NeedAdd = true, typename It >
YACLIB_INLINE void Attach (It begin, std::size_t count) noexcept
 Attach Future to WaitGroup with auto Done.
 
YACLIB_INLINE void Wait () noexcept
 TODO.
 
template<typename Rep , typename Period >
YACLIB_INLINE bool WaitFor (const std::chrono::duration< Rep, Period > &timeout_duration)
 TODO.
 
template<typename Clock , typename Duration >
YACLIB_INLINE bool WaitUntil (const std::chrono::time_point< Clock, Duration > &timeout_time)
 TODO.
 
YACLIB_INLINE void Reset (std::size_t count=0) noexcept
 Reinitializes WaitGroup, semantically the same as *this = {};
 

Detailed Description

template<typename Event = OneShotEvent>
class yaclib::WaitGroup< Event >

An object that allows you to Add some amount of async operations and then Wait for it to be Done.

Definition at line 18 of file wait_group.hpp.

Constructor & Destructor Documentation

◆ WaitGroup()

template<typename Event = OneShotEvent>
yaclib::WaitGroup< Event >::WaitGroup ( std::size_t  count = 0)
inlineexplicitnoexcept

Definition at line 20 of file wait_group.hpp.

Member Function Documentation

◆ Add()

template<typename Event = OneShotEvent>
YACLIB_INLINE void yaclib::WaitGroup< Event >::Add ( std::size_t  count = 1)
inlinenoexcept

Add some amount of async operations.

Can be called parallel with Add, Done, and with Wait, but only if you call it when some Add not Done yet

Parameters
countof async operations

Definition at line 31 of file wait_group.hpp.

◆ Attach() [1/3]

template<typename Event = OneShotEvent>
template<bool NeedAdd = true, typename... V, typename... E>
YACLIB_INLINE void yaclib::WaitGroup< Event >::Attach ( FutureBase< V, E > &...  futures)
inlinenoexcept

Attach Future to WaitGroup with auto Done.

Also

See also
Add
Template Parameters
NeedAddif true make implicit Add, if false you should make explicit Add before call Attach
Parameters
futuresto wait

Definition at line 94 of file wait_group.hpp.

References yaclib::MakeContract().

◆ Attach() [2/3]

template<typename Event = OneShotEvent>
template<bool NeedAdd = true, typename It >
YACLIB_INLINE std::enable_if_t<!is_future_base_v< It >, void > yaclib::WaitGroup< Event >::Attach ( It  begin,
It  end 
)
inlinenoexcept

Attach Future to WaitGroup with auto Done.

Also

See also
Add
Template Parameters
NeedAddif true make implicit Add, if false you should make explicit Add before call Attach
Parameters
beginiterator to futures to Add
enditerator to futures to Add

Definition at line 108 of file wait_group.hpp.

References yaclib::MakeContract().

◆ Attach() [3/3]

template<typename Event = OneShotEvent>
template<bool NeedAdd = true, typename It >
YACLIB_INLINE void yaclib::WaitGroup< Event >::Attach ( It  begin,
std::size_t  count 
)
inlinenoexcept

Attach Future to WaitGroup with auto Done.

Also

See also
Add
Template Parameters
NeedAddif true make implicit Add, if false you should make explicit Add before call Attach
Parameters
beginiterator to futures to Add
countcount of futures to Add

Definition at line 122 of file wait_group.hpp.

References yaclib::MakeContract().

◆ Consume() [1/3]

template<typename Event = OneShotEvent>
template<bool NeedAdd = true, typename... V, typename... E>
YACLIB_INLINE void yaclib::WaitGroup< Event >::Consume ( FutureBase< V, E > &&...  futures)
inlinenoexcept

Consume Future by WaitGroup with auto Done.

Also

See also
Add
Template Parameters
NeedAddif true make implicit Add, if false you should make explicit Add before call Consume
Parameters
futuresto wait

Definition at line 53 of file wait_group.hpp.

References yaclib::MakeContract().

◆ Consume() [2/3]

template<typename Event = OneShotEvent>
template<bool NeedAdd = true, typename It >
YACLIB_INLINE std::enable_if_t<!is_future_base_v< It >, void > yaclib::WaitGroup< Event >::Consume ( It  begin,
It  end 
)
inlinenoexcept

Consume Future by WaitGroup with auto Done.

Also

See also
Add
Template Parameters
NeedAddif true make implicit Add, if false you should make explicit Add before call Consume
Parameters
beginiterator to futures to Add
enditerator to futures to Add

Definition at line 67 of file wait_group.hpp.

References yaclib::MakeContract().

◆ Consume() [3/3]

template<typename Event = OneShotEvent>
template<bool NeedAdd = true, typename It >
YACLIB_INLINE void yaclib::WaitGroup< Event >::Consume ( It  begin,
std::size_t  count 
)
inlinenoexcept

Consume Future by WaitGroup with auto Done.

Also

See also
Add
Template Parameters
NeedAddif true make implicit Add, if false you should make explicit Add before call Consume
Parameters
beginiterator to futures to Add
countcount of futures to Add

Definition at line 81 of file wait_group.hpp.

References yaclib::MakeContract().

◆ Done()

template<typename Event = OneShotEvent>
YACLIB_INLINE void yaclib::WaitGroup< Event >::Done ( std::size_t  count = 1)
inlinenoexcept

Done some Add-ed async operations.

Parameters
countof async operations

Definition at line 40 of file wait_group.hpp.

◆ Reset()

template<typename Event = OneShotEvent>
YACLIB_INLINE void yaclib::WaitGroup< Event >::Reset ( std::size_t  count = 0)
inlinenoexcept

Reinitializes WaitGroup, semantically the same as *this = {};

If you don't explicitly call this method, then after the first one, Wait will always return immediately.

Note
Not thread-safe

Definition at line 188 of file wait_group.hpp.

◆ Wait()

template<typename Event = OneShotEvent>
YACLIB_INLINE void yaclib::WaitGroup< Event >::Wait ( )
inlinenoexcept

TODO.

Definition at line 129 of file wait_group.hpp.

◆ WaitFor()

template<typename Event = OneShotEvent>
template<typename Rep , typename Period >
YACLIB_INLINE bool yaclib::WaitGroup< Event >::WaitFor ( const std::chrono::duration< Rep, Period > &  timeout_duration)
inline

TODO.

Definition at line 136 of file wait_group.hpp.

References yaclib::MakeContract().

◆ WaitUntil()

template<typename Event = OneShotEvent>
YACLIB_INLINE bool yaclib::WaitGroup< Event >::WaitUntil ( const std::chrono::time_point< Clock, Duration > &  timeout_time)
inline

TODO.

Definition at line 144 of file wait_group.hpp.

References yaclib::MakeContract().


The documentation for this class was generated from the following file: