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
3
#include <
yaclib/algo/detail/result_core.hpp
>
4
5
namespace
yaclib::detail
{
6
7
template
<
typename
V,
typename
E>
8
class
SharedCore
:
public
ResultCore
<V, E> {
9
using
ResultCore
<V,
E
>
::ResultCore
;
10
11
public
:
12
[[
nodiscard
]]
InlineCore
*
Here
(
InlineCore
& caller)
noexcept
override
{
13
return
ResultCore<V, E>::template
Impl<false, true>
(caller);
14
}
15
16
#if YACLIB_SYMMETRIC_TRANSFER != 0
17
[[
nodiscard
]] yaclib_std::coroutine_handle<>
Next
(
InlineCore
& caller)
noexcept
override
{
18
return
ResultCore<V, E>::template
Impl<true, true>
(caller);
19
}
20
#endif
21
22
[[
nodiscard
]]
bool
SetCallback
(
InlineCore
&
callback
)
noexcept
{
23
return
BaseCore::SetCallbackImpl<true>(
callback
);
24
}
25
26
// Users should be cautious calling SetInline on a SharedCore
27
// because the core's lifetime is managed by the SharedPromise and
28
// SharedFutures and they might all be gone by the time
29
// the callback is called
30
template
<
bool
SymmetricTransfer>
31
[[
nodiscard
]]
Transfer<SymmetricTransfer>
SetInline
(
InlineCore
&
callback
)
noexcept
{
32
return
BaseCore::SetInlineImpl<SymmetricTransfer, true>(
callback
);
33
}
34
35
template
<
bool
SymmetricTransfer>
36
[[
nodiscard
]]
Transfer<SymmetricTransfer>
SetResult
()
noexcept
{
37
return
BaseCore::SetResultImpl<SymmetricTransfer, true>();
38
}
39
};
40
41
extern
template
class
SharedCore<void, StopError>
;
42
43
template
<
typename
V,
typename
E>
44
using
SharedCorePtr
=
IntrusivePtr<SharedCore<V, E>
>;
45
46
}
// namespace yaclib::detail
yaclib::IntrusivePtr
A intrusive pointer to objects with an embedded reference count.
Definition
intrusive_ptr.hpp:17
yaclib::detail::InlineCore
Definition
inline_core.hpp:13
yaclib::detail::ResultCore
Definition
result_core.hpp:17
yaclib::detail::ResultCore::ResultCore
ResultCore() noexcept
Definition
result_core.hpp:19
yaclib::detail::SharedCore
Definition
shared_core.hpp:8
yaclib::detail::SharedCore::Here
InlineCore * Here(InlineCore &caller) noexcept override
Definition
shared_core.hpp:12
yaclib::detail::SharedCore::SetResult
Transfer< SymmetricTransfer > SetResult() noexcept
Definition
shared_core.hpp:36
yaclib::detail::SharedCore::SetCallback
bool SetCallback(InlineCore &callback) noexcept
Definition
shared_core.hpp:22
yaclib::detail::SharedCore::SetInline
Transfer< SymmetricTransfer > SetInline(InlineCore &callback) noexcept
Definition
shared_core.hpp:31
yaclib::detail
Definition
base_core.hpp:14
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
result_core.hpp
include
yaclib
algo
detail
shared_core.hpp
Generated by
1.9.8