6#include <yaclib/config.hpp>
17template <
typename Event = OneShotEvent>
52 template <
bool NeedAdd =
true,
typename... V,
typename...
E>
66 template <
bool NeedAdd = true,
typename It>
80 template <
bool NeedAdd = true,
typename It>
93 template <
bool NeedAdd =
true,
typename... V,
typename...
E>
107 template <
bool NeedAdd = true,
typename It>
121 template <
bool NeedAdd = true,
typename It>
135 template <
typename Rep,
typename Period>
143 template <
typename Clock,
typename Duration>
153 return _event.Await();
160 return _event.AwaitSticky();
167 return _event.AwaitOn(
e);
190 _event.count.store(count, std::memory_order_relaxed);
196 static_assert(
sizeof...(cores) >= 1,
"Number of futures must be at least one");
197 static_assert((... && std::is_same_v<detail::BaseCore, Cores>),
198 "Futures must be Future in WaitGroup::Consume/Attach function");
200 return (... +
static_cast<std::size_t
>(
func(
cores)));
205 template <
bool NeedMove,
bool NeedAdd,
typename It>
208 "WaitGroup::Consume/Attach function Iterator must be point to some Future");
214 for (std::size_t
i = 0;
i != count; ++
i) {
227 template <
bool NeedMove,
bool NeedAdd,
typename Range>
228 void InsertRange(
const Range&
range, std::size_t count)
noexcept {
234 if (
core.SetCallback(_event.GetDrop())) {
240 return core.SetCallback(_event.GetCall());
247 detail::MultiEvent<Event, detail::AtomicCounter, detail::CallCallback, detail::DropCallback> _event;
Provides a mechanism to access the result of async operations.
An object that allows you to Add some amount of async operations and then Wait for it to be Done.
YACLIB_INLINE void Reset(std::size_t count=0) noexcept
Reinitializes WaitGroup, semantically the same as *this = {};
YACLIB_INLINE void Wait() noexcept
TODO.
YACLIB_INLINE void Done(std::size_t count=1) noexcept
Done some Add-ed async operations.
YACLIB_INLINE void Add(std::size_t count=1) noexcept
Add some amount of async operations.
YACLIB_INLINE void Attach(FutureBase< V, E > &... futures) noexcept
Attach Future to WaitGroup with auto Done.
YACLIB_INLINE void Attach(It begin, std::size_t count) noexcept
Attach Future to WaitGroup with auto Done.
YACLIB_INLINE void Consume(FutureBase< V, E > &&... futures) noexcept
Consume Future by WaitGroup with auto Done.
YACLIB_INLINE std::enable_if_t<!is_future_base_v< It >, void > Consume(It begin, It end) noexcept
Consume Future by WaitGroup with auto Done.
YACLIB_INLINE bool WaitFor(const std::chrono::duration< Rep, Period > &timeout_duration)
TODO.
WaitGroup(std::size_t count=0) noexcept
YACLIB_INLINE void Consume(It begin, std::size_t count) noexcept
Consume Future by WaitGroup with auto Done.
YACLIB_INLINE bool WaitUntil(const std::chrono::time_point< Clock, Duration > &timeout_time)
TODO.
YACLIB_INLINE std::enable_if_t<!is_future_base_v< It >, void > Attach(It begin, It end) noexcept
Attach Future to WaitGroup with auto Done.
YACLIB_INLINE auto AwaitOn(IExecutor &e, FutureBase< V, E > &... fs) noexcept
YACLIB_INLINE auto Await(Task< V, E > &task) noexcept
TODO(mkornaukhov03) Add doxygen docs.
Contract< V, E > MakeContract()
Creates related future and promise.