YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
shared_core.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace yaclib::detail {
6
7// 3 refs for the promise (1 for the promise itself and 2 for the last callback)
8// 1 ref for the future
9inline constexpr size_t kSharedRefWithFuture = 4;
10inline constexpr size_t kSharedRefNoFuture = 3;
11
12template <typename V, typename E>
13class SharedCore : public ResultCore<V, E> {
14 using ResultCore<V, E>::ResultCore;
15
16 public:
17 [[nodiscard]] InlineCore* Here(InlineCore& caller) noexcept override {
19 }
20
21#if YACLIB_SYMMETRIC_TRANSFER != 0
22 [[nodiscard]] yaclib_std::coroutine_handle<> Next(InlineCore& caller) noexcept override {
24 }
25#endif
26
28 return BaseCore::SetCallbackImpl<true>(callback);
29 }
30
31 // Users should be cautious calling SetInline on a SharedCore
32 // because the core's lifetime is managed by the SharedPromise and
33 // SharedFutures and they might all be gone by the time
34 // the callback is called
35 template <bool SymmetricTransfer>
37 return BaseCore::SetInlineImpl<SymmetricTransfer, true>(callback);
38 }
39
40 template <bool SymmetricTransfer>
42 return BaseCore::SetResultImpl<SymmetricTransfer, true>();
43 }
44};
45
46extern template class SharedCore<void, StopError>;
47
48template <typename V, typename E>
50
51} // namespace yaclib::detail
A intrusive pointer to objects with an embedded reference count.
InlineCore * Here(InlineCore &caller) noexcept override
Transfer< SymmetricTransfer > SetResult() noexcept
bool SetCallback(InlineCore &callback) noexcept
Transfer< SymmetricTransfer > SetInline(InlineCore &callback) noexcept
constexpr size_t kSharedRefWithFuture
constexpr size_t kSharedRefNoFuture
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25