6#include <yaclib/config.hpp>
16void Start(BaseCore*
head, IExecutor&
e)
noexcept;
25template <
typename V,
typename T>
30 static_assert(
Check<V>(),
"V should be valid");
33 static_assert(!std::is_same_v<V, typename T::Error>,
34 "V cannot be the same as the trait Error type, because callback dispatch would be ambiguous");
50 return _core !=
nullptr;
60 return !_core->Empty();
69 return {std::move(this->_core)};
72 template <
typename Func>
75 static constexpr auto CoreT = CoreType::ToUnique | CoreType::Call | CoreType::Lazy;
76 return detail::SetCallback<CoreT, false>(_core, &
e, std::forward<Func>(
f));
78 template <
typename Func>
81 static constexpr auto CoreT = CoreType::ToUnique | CoreType::Lazy;
82 return detail::SetCallback<CoreT, false>(_core,
nullptr, std::forward<Func>(
f));
84 template <
typename Func>
87 static constexpr auto CoreT = CoreType::ToUnique | CoreType::Call | CoreType::Lazy;
88 return detail::SetCallback<CoreT, false>(_core,
nullptr, std::forward<Func>(
f));
97 auto* core = _core.Release();
103 auto* core = _core.Release();
111 return {std::move(_core)};
116 return {std::move(_core)};
121 return std::move(*this).ToFuture().Get();
133 auto core = std::exchange(_core,
nullptr);
134 return std::move(core->Get());
149 detail::UniqueCorePtr<V, T> _core;
152extern template class Task<>;
Provides a mechanism to access the result of async operations.
Provides a mechanism to access the result of async operations.
A intrusive pointer to objects with an embedded reference count.
Provides a mechanism to schedule the some async operations TODO(MBkkt) add description.
Task & operator=(const Task &)=delete
detail::UniqueCorePtr< V, T > & GetCore() noexcept
Method that get internal Core state.
Future< V, T > ToFuture() &&noexcept
void Detach(IExecutor &e) &&noexcept
Task & operator=(Task &&other) noexcept=default
auto Then(IExecutor &e, Func &&f) &&
bool Ready() const &noexcept
Check that Result that corresponds to this Task is computed.
void Touch() const &&=delete
Task(detail::UniqueCorePtr< V, T > core) noexcept
bool Valid() const &noexcept
typename T::template Result< V > Result
Task(Task &&other) noexcept=default
Task< V, T > On(std::nullptr_t) &&noexcept
Do nothing, just for compatibility with FutureOn TODO(MBkkt) think about force On/Detach/ToFuture: It...
Task(const Task &)=delete
auto ThenInline(Func &&f) &&
FutureOn< V, T > ToFuture(IExecutor &e) &&noexcept
Result Touch() &&noexcept
#define YACLIB_ASSERT(cond)
InlineCore & MakeDrop() noexcept
void Start(BaseCore *head, IExecutor &e) noexcept
Contract< V, T > MakeContract()
Creates related future and promise.
IExecutor & MakeInline() noexcept
Get Inline executor singleton object.