6#include <yaclib/config.hpp>
17template <
typename Event = OneShotEvent>
45 return _event.Get(
order);
56 template <
bool NeedAdd =
true,
typename... V,
typename...
E>
70 template <
bool NeedAdd = true,
typename It>
84 template <
bool NeedAdd = true,
typename It>
97 template <
bool NeedAdd =
true,
typename... V,
typename...
E>
111 template <
bool NeedAdd = true,
typename It>
125 template <
bool NeedAdd = true,
typename It>
139 template <
typename Rep,
typename Period>
147 template <
typename Clock,
typename Duration>
157 return _event.Await();
164 return _event.AwaitSticky();
171 return _event.AwaitOn(
e);
194 _event.count.store(count, std::memory_order_relaxed);
200 static_assert(
sizeof...(cores) >= 1,
"Number of futures must be at least one");
201 static_assert((... && std::is_same_v<detail::BaseCore, Cores>),
202 "Futures must be Future in WaitGroup::Consume/Attach function");
204 return (... +
static_cast<std::size_t
>(
func(
cores)));
209 template <
bool NeedMove,
bool NeedAdd,
typename It>
212 "WaitGroup::Consume/Attach function Iterator must be point to some Future");
218 for (std::size_t
i = 0;
i != count; ++
i) {
231 template <
bool NeedMove,
bool NeedAdd,
typename Range>
232 void InsertRange(
const Range&
range, std::size_t count)
noexcept {
238 if (
core.SetCallback(_event.GetDrop())) {
244 return core.SetCallback(_event.GetCall());
251 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 std::size_t Count(std::memory_order order=std::memory_order_relaxed) const noexcept
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.