YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
unique_core.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <type_traits>
6
7namespace yaclib::detail {
8
9template <typename V, typename T>
10class UniqueCore : public ResultCore<V, T> {
11 using ResultCore<V, T>::ResultCore;
12
13 public:
15
16 [[nodiscard]] InlineCore* Here(InlineCore& caller) noexcept override {
18 }
19
20#if YACLIB_SYMMETRIC_TRANSFER != 0
21 [[nodiscard]] yaclib_std::coroutine_handle<> Next(InlineCore& caller) noexcept override {
23 }
24#endif
25
27 if constexpr (std::is_move_constructible_v<wrap_void_t<V>>) {
28 auto result = std::move(this->Get());
29 this->DecRef();
30 return result;
31 } else {
33 return {};
34 }
35 }
36
40
42 return BaseCore::SetCallbackImpl<false>(callback);
43 }
44
45 // Sometimes we know it will be last callback in cycle, so we want call it right now, instead of SetInline
46 void CallInline(InlineCore& callback) noexcept {
47 if (!SetCallback(callback)) {
48 [[maybe_unused]] auto* next = callback.Here(*this);
49 YACLIB_ASSERT(next == nullptr);
50 }
51 }
52
53 template <bool SymmetricTransfer>
55 return BaseCore::SetInlineImpl<SymmetricTransfer, false>(callback);
56 }
57
58 template <bool SymmetricTransfer>
60 return BaseCore::SetResultImpl<SymmetricTransfer, false>();
61 }
62};
63
64extern template class UniqueCore<void, DefaultTrait>;
65
66template <typename V, typename T>
68
69} // namespace yaclib::detail
virtual void DecRef() noexcept
Decrements reference counter.
Definition ref.hpp:23
A intrusive pointer to objects with an embedded reference count.
void StoreCallbackImpl(InlineCore &callback) noexcept
Definition base_core.hpp:53
Result & Get() noexcept
typename T::template Result< V > Result
typename ResultCore< V, T >::Result Result
Transfer< SymmetricTransfer > SetResult() noexcept
Transfer< SymmetricTransfer > SetInline(InlineCore &callback) noexcept
void CallInline(InlineCore &callback) noexcept
bool SetCallback(InlineCore &callback) noexcept
InlineCore * Here(InlineCore &caller) noexcept override
void StoreCallback(InlineCore &callback) noexcept
#define YACLIB_ASSERT(cond)
Definition log.hpp:85
#define YACLIB_PURE_VIRTUAL()
Definition log.hpp:86
Contract< V, T > MakeContract()
Creates related future and promise.
Definition contract.hpp:25