19template <
typename V,
typename E>
22 static_assert(
Check<V>(),
"V should be valid");
23 static_assert(
Check<E>(),
"E should be valid");
24 static_assert(!std::is_same_v<V, E>,
"Future cannot be instantiated with same V and E, because it's ambiguous");
54 return _core !=
nullptr;
64 return !
_core->Empty();
67 void Get() & =
delete;
94 auto core = std::exchange(
_core,
nullptr);
95 return std::move(
core->Get());
118 auto core = std::exchange(
_core,
nullptr);
119 return std::move(
core->Get());
131 template <
typename Func>
134 "better way is use ThenInline(...) instead of Then(MakeInline(), ...)");
135 return detail::SetCallback<detail::CoreType::Then, detail::CallbackType::On>(
_core, &
e, std::forward<Func>(
f));
154 template <
typename Func>
156 detail::SetCallback<detail::CoreType::Detach, detail::CallbackType::Inline>(
_core,
nullptr, std::forward<Func>(
f));
167 template <
typename Func>
170 "better way is use DetachInline(...) instead of Detach(MakeInline(), ...)");
171 detail::SetCallback<detail::CoreType::Detach, detail::CallbackType::On>(
_core, &
e, std::forward<Func>(
f));
198template <
typename V,
typename E>
216 template <
typename Func>
218 return detail::SetCallback<detail::CoreType::Then, detail::CallbackType::Inline>(this->_core,
nullptr,
219 std::forward<Func>(
f));
231template <
typename V,
typename E>
248 return {std::move(this->_core)};
259 template <
typename Func>
261 return detail::SetCallback<detail::CoreType::Then, detail::CallbackType::InlineOn>(this->_core,
nullptr,
262 std::forward<Func>(
f));
272 template <
typename Func>
274 return detail::SetCallback<detail::CoreType::Then, detail::CallbackType::On>(this->_core,
nullptr,
275 std::forward<Func>(
f));
284 template <
typename Func>
286 detail::SetCallback<detail::CoreType::Detach, detail::CallbackType::On>(this->_core,
nullptr,
287 std::forward<Func>(
f));
Provides a mechanism to access the result of async operations.
void DetachInline(Func &&f) &&
Attach the final continuation func to *this and Detach *this.
Result< V, E > Get() &&noexcept
FutureBase & operator=(const FutureBase &)=delete
detail::ResultCorePtr< V, E > & GetCore() noexcept
Method that get internal Core state.
bool Valid() const &noexcept
Check if this Future has Promise.
Result< V, E > Touch() &&noexcept
FutureBase(detail::ResultCorePtr< V, E > core) noexcept
FutureBase(FutureBase &&other) noexcept=default
void Detach() &&noexcept
Disable calling Stop in destructor.
FutureBase() noexcept=default
The default constructor creates not a Valid Future.
void Detach(IExecutor &e, Func &&f) &&
Attach the final continuation func to *this and Detach *this.
auto Then(IExecutor &e, Func &&f) &&
Attach the continuation func to *this.
detail::ResultCorePtr< V, E > _core
FutureBase(const FutureBase &)=delete
FutureBase & operator=(FutureBase &&other) noexcept=default
const Result< V, E > & Touch() const &noexcept
bool Ready() const &noexcept
Check that Result that corresponds to this Future is computed.
void Get() const &&=delete
Provides a mechanism to access the result of async operations.
Future< V, E > On(std::nullptr_t) &&noexcept
Specify executor for continuation.
void Detach(Func &&f) &&
Attach the final continuation func to *this and Detach *this.
auto ThenInline(Func &&f) &&
Attach the continuation func to *this.
auto Then(Func &&f) &&
Attach the continuation func to *this.
FutureOn(detail::ResultCorePtr< V, E > core) noexcept
Provides a mechanism to access the result of async operations.
Future(detail::ResultCorePtr< V, E > core) noexcept
auto ThenInline(Func &&f) &&
Attach the continuation func to *this.
A intrusive pointer to objects with an embedded reference count.
Encapsulated return value from caller.
#define YACLIB_WARN(cond, message)
#define YACLIB_ASSERT(cond)
InlineCore & MakeDrop() noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
YACLIB_INLINE void Wait(FutureBase< V, E > &... fs) noexcept
Wait until Ready becomes true.