13template <
typename V,
typename T>
18 static_assert(
Check<V>(),
"V should be valid");
19 static_assert(!std::is_same_v<V, typename T::Error>,
20 "V cannot be the same as the trait Error type, because callback dispatch would be ambiguous");
21 static_assert(std::is_copy_constructible_v<wrap_void_t<V>>,
"Result should be copyable");
28 return _core !=
nullptr;
33 return !
_core->Empty();
39 if (
_core->GetRef() == 1) {
40 return std::move(
_core->Get());
57 if (
_core->GetRef() == 1) {
58 return std::move(
_core->Get());
72 template <
typename Func>
75 "better way is use ThenInline(...) instead of Then(MakeInline(), ...)");
76 static constexpr auto CoreT = CoreType::ToUnique | CoreType::Call;
77 return detail::SetCallback<CoreT, true>(
_core, &
e, std::forward<Func>(
f));
84 template <
typename Func>
86 static constexpr auto CoreT = CoreType::Detach;
87 detail::SetCallback<CoreT, false>(
_core,
nullptr, std::forward<Func>(
f));
90 template <
typename Func>
93 "better way is use SubscribeInline(...) instead of Subscribe(MakeInline(), ...)");
94 static constexpr auto CoreT = CoreType::Detach | CoreType::Call;
95 detail::SetCallback<CoreT, true>(
_core, &
e, std::forward<Func>(
f));
122template <
typename V,
typename T>
133 template <
typename Func>
135 static constexpr auto CoreT = CoreType::ToUnique;
136 return detail::SetCallback<CoreT, false>(this->_core,
nullptr, std::forward<Func>(
f));
142template <
typename V,
typename T>
156 return {std::move(this->_core)};
159 template <
typename Func>
161 static constexpr auto CoreT = CoreType::ToUnique;
162 return detail::SetCallback<CoreT, true>(this->_core,
nullptr, std::forward<Func>(
f));
165 template <
typename Func>
167 static constexpr auto CoreT = CoreType::ToUnique | CoreType::Call;
168 return detail::SetCallback<CoreT, true>(this->_core,
nullptr, std::forward<Func>(
f));
171 template <
typename Func>
173 static constexpr auto CoreT = CoreType::Detach | CoreType::Call;
174 detail::SetCallback<CoreT, false>(this->_core,
nullptr, std::forward<Func>(
f));
A intrusive pointer to objects with an embedded reference count.
SharedFutureBase(detail::SharedCorePtr< V, T > core) noexcept
const detail::SharedCorePtr< V, T > & GetCore() const noexcept
typename T::template Result< V > Result
auto Then(IExecutor &e, Func &&f) const
Result Touch() &&noexcept
void Subscribe(IExecutor &e, Func &&f) const
SharedFutureBase()=default
bool Valid() const noexcept
bool Ready() const noexcept
void Touch() const &&=delete
detail::SharedCorePtr< V, T > _core
detail::SharedCorePtr< V, T > & GetCore() noexcept
void SubscribeInline(Func &&f) const
detail::SharedHandle GetHandle() const noexcept
void Get() const &&=delete
auto Then(Func &&f) const
SharedFutureOn(detail::SharedCorePtr< V, T > core) noexcept
SharedFuture< V, T > On(std::nullptr_t) &&noexcept
auto ThenInline(Func &&f) const
void Subscribe(Func &&f) const
SharedFuture(detail::SharedCorePtr< V, T > core) noexcept
auto ThenInline(Func &&f) const
#define YACLIB_WARN(cond, message)
#define YACLIB_ASSERT(cond)
Contract< V, T > MakeContract()
Creates related future and promise.
YACLIB_INLINE std::enable_if_t<(... &&is_waitable_v< Waited >), void > Wait(Waited &... fs) noexcept
Wait until Ready becomes true.