41 template<
typename... Values>
47 template<
typename Send>
68 template<
typename SharedState>
75 template<
typename... Args>
77 self.state->complete_with(
set_value, util::forward<Args>(values)...);
82 self.state->complete_with(
set_error, util::forward<E>(error));
93 template<
typename SharedState>
96 template<
typename Send,
typename SenderAttr,
typename Alloc>
115 explicit Type(Send&& sender, A&& allocator_)
120 template<
typename... Args>
150 auto* pointer =
this;
166 template<
typename Send,
typename SenderAttr,
typename Alloc>
169 template<
typename Send,
typename Rec,
typename SenderAttr,
typename Alloc>
177 auto& self = *
static_cast<Type*
>(void_self);
180 self.m_stop_callback.reset();
183 auto& state = *self.m_state;
185 [&](
auto const& tuple) {
187 [&](
auto tag,
auto const&... values) {
189 set_value(util::move(self.m_receiver), values...);
191 set_error(util::move(self.m_receiver), values...);
196 util::forward<decltype(tuple)>(tuple));
198 util::as_const(state.storage));
201 , m_receiver(util::forward<Rec>(receiver)) {}
203 ~Type() { m_state->drop_ref_count(); }
207 auto& state = *self.m_state;
215 auto* sentinel =
static_cast<void*
>(self.m_state);
217 if (old_head == sentinel) {
219 self.did_complete(util::addressof(self));
224 }
while (!state.waiting.compare_exchange_weak(old_head,
static_cast<void*
>(util::addressof(self)),
231 if (old_head ==
nullptr) {
234 if (state.stop_source.stop_requested()) {
235 state.did_complete();
238 start(state.operation);
250 template<
typename Send,
typename Rec,
typename SenderAttr,
typename Alloc>
253 template<
typename Send,
typename Alloc>
267 m_state->bump_ref_count();
275 state->drop_ref_count();
281 if (m_state != other.m_state) {
284 state->drop_ref_count();
287 m_state->bump_ref_count();
298 template<concepts::ReceiverOf<CompletionSignatures> Rec>
301 self.m_state->bump_ref_count();
305 template<concepts::ReceiverOf<CompletionSignatures> Rec>
309 util::move(receiver));
314 return self.m_state->sender_attr;
317 State* m_state {
nullptr };
321 template<
typename Send,
typename Alloc>
325 template<concepts::SenderIn<Env> Send, concepts::Allocator Alloc = platform::DefaultAllocator>
327 auto operator()(Send&& sender, Alloc&& allocator = {})
const {
328 if constexpr (
requires {
330 util::forward<Send>(sender), util::forward<Alloc>(allocator));
333 util::forward<Send>(sender), util::forward<Alloc>(allocator));
334 }
else if constexpr (
requires {
335 tag_invoke(*
this, util::forward<Send>(sender), util::forward<Alloc>(allocator));
337 return tag_invoke(*
this, util::forward<Send>(sender), util::forward<Alloc>(allocator));
341 util::construct_at(state, util::forward<Send>(sender), util::forward<Alloc>(allocator));
#define DI_ASSERT(...)
Definition assert_bool.h:7
Definition in_place_stop_source.h:11
Definition in_place_stop_token.h:6
Definition optional_forward_declaration.h:5
Definition tuple_forward_declaration.h:5
Definition variant_forward_declaration.h:6
#define DI_IMMOVABLE_NO_UNIQUE_ADDRESS
Definition compiler.h:15
constexpr auto allocate_one
Definition allocate_one.h:29
constexpr auto deallocate_one
Definition deallocate_one.h:27
meta::Type< OperationStateT< Send, Rec, SenderAttr, Alloc > > OperationState
Definition split.h:251
MakeEnv< EmptyEnv, With< Tag< get_stop_token >, StopToken > > Env
Definition split.h:39
CompletionSignatures< SetError(meta::Decay< DecayedCLValue< E > >)> SigSetError
Definition split.h:45
meta::Type< SharedStateT< Send, meta::Decay< SenderAttr >, meta::Decay< Alloc > > > SharedState
Definition split.h:167
sync::InPlaceStopToken StopToken
Definition split.h:34
meta::Type< OperationStateBaseT > OperationStateBase
Definition split.h:66
meta::MakeCompletionSignatures< Send, Env, CompletionSignatures< SetStopped()>, SigSetValue, SigSetError > Sigs
Definition split.h:48
meta::Type< SenderT< Send, meta::Decay< Alloc > > > Sender
Definition split.h:322
CompletionSignatures< SetValue(meta::Decay< DecayedCLValue< Values > >...)> SigSetValue
Definition split.h:42
meta::Decay< T > const & DecayedCLValue
Definition split.h:37
meta::Type< SharedReceiverT< SharedState > > SharedReceiver
Definition split.h:94
sync::InPlaceStopSource StopSource
Definition split.h:33
constexpr auto set_error
Definition set_error.h:14
constexpr auto start
Definition start.h:20
constexpr auto make_env
Create an environment with overrides for queries.
Definition make_env.h:147
constexpr auto set_stopped
Definition set_stopped.h:14
constexpr auto with
Specify an override for an environment query.
Definition make_env.h:112
constexpr auto split
Split a sender into a sender which sends the same value to multiple receivers.
Definition split.h:361
constexpr auto get_completion_scheduler
Definition get_completion_scheduler.h:19
constexpr auto get_stop_token
Definition get_stop_token.h:25
decltype(make_env(util::declval< BaseEnv >(), util::declval< Withs >()...)) MakeEnv
Represent an environment with overrides for queries.
Definition make_env.h:189
constexpr auto get_env
Definition get_env.h:27
constexpr auto connect
Definition connect.h:42
constexpr auto set_value
Definition set_value.h:14
constexpr auto curry_back
Definition curry_back.h:141
@ Relaxed
Definition memory_order.h:7
@ AcquireRelease
Definition memory_order.h:11
@ Acquire
Definition memory_order.h:9
@ Release
Definition memory_order.h:10
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
constexpr auto exchange(T &object, U &&new_value) -> T
Definition exchange.h:8
constexpr auto destroy_at
Definition destroy_at.h:24
constexpr auto construct_at
Definition construct_at.h:27
constexpr auto apply(F &&f, Tup &&tuple) -> decltype(detail::apply_impl(meta::MakeIndexSequence< meta::TupleSize< Tup > > {}, util::forward< F >(f), util::forward< Tup >(tuple)))
Definition apply.h:22
constexpr auto as_fallible
Definition as_fallible.h:26
constexpr auto try_infallible
Definition try_infallible.h:31
constexpr auto visit(Vis &&visitor, Vars &&... variants) -> R
Definition visit.h:39
constexpr tag_invoke_detail::TagInvokeFn tag_invoke
Definition tag_invoke.h:22
constexpr auto exchange(T &object, U &&new_value) -> T
Definition exchange.h:8
constexpr auto c_
A value of type Constexpr<val>.
Definition constexpr.h:252
constexpr auto empty_env
Definition empty_env.h:6
Definition set_stopped.h:6
Type * next
Definition split.h:62
void(* did_complete)(Type *)
Definition split.h:61
Type(void(*did_complete_)(Type *))
Definition split.h:59
Type(State *state, Rec receiver)
Definition split.h:175
friend void tag_invoke(Tag< start >, Type &self)
Definition split.h:206
SharedState< Send, SenderAttr, Alloc > State
Definition split.h:173
~Type()
Definition split.h:203
Type(Type &&other)
Definition split.h:270
~Type()
Definition split.h:272
SharedState< Send, meta::EnvOf< Send >, Alloc > State
Definition split.h:261
void is_sender
Definition split.h:257
Type(Type const &other)
Definition split.h:265
auto operator=(Type &&other) -> Type &
Definition split.h:292
auto operator=(Type const &other) -> Type &
Definition split.h:280
Sigs< Send > CompletionSignatures
Definition split.h:259
friend auto tag_invoke(Tag< connect >, Type &&self, Rec receiver)
Definition split.h:306
friend auto tag_invoke(Tag< get_env >, Type const &self) -> meta::Decay< meta::EnvOf< Send > > const &
Definition split.h:312
friend auto tag_invoke(Tag< connect >, Type const &self, Rec receiver)
Definition split.h:299
Type(State *state)
Definition split.h:263
friend void tag_invoke(Tag< set_error >, Type &&self, E &&error)
Definition split.h:81
friend void tag_invoke(Tag< set_stopped >, Type &&self)
Definition split.h:85
SharedState * state
Definition split.h:73
friend auto tag_invoke(Tag< get_env >, Type const &self) -> Env
Definition split.h:87
friend void tag_invoke(Tag< set_value >, Type &&self, Args &&... values)
Definition split.h:76
void is_receiver
Definition split.h:71
Alloc allocator
Definition split.h:161
void drop_ref_count()
Definition split.h:145
StopSource stop_source
Definition split.h:157
SenderAttr sender_attr
Definition split.h:158
void did_complete()
Definition split.h:127
void bump_ref_count()
Definition split.h:144
meta::Transform< Completions, meta::Quote< meta::AsList > > DecayedArgs
Definition split.h:103
meta::AsTemplate< vocab::Variant, meta::Unique< meta::PushFront< meta::Transform< meta::Zip< Tags, DecayedArgs >, meta::Compose< meta::Uncurry< meta::Quote< meta::DecayedTuple > >, meta::Quote< meta::Join > > >, vocab::Tuple< SetStopped > > > > Storage
Definition split.h:104
meta::Transform< Completions, meta::Compose< meta::Quote< meta::List >, meta::Quote< meta::LanguageFunctionReturn > > > Tags
Definition split.h:100
void complete_with(Args &&... args)
Definition split.h:121
DI_IMMOVABLE_NO_UNIQUE_ADDRESS Op operation
Definition split.h:162
meta::AsList< meta::CompletionSignaturesOf< Send, Env > > Completions
Definition split.h:99
Storage storage
Definition split.h:156
sync::Atomic< void * > waiting
Definition split.h:160
sync::Atomic< usize > ref_count
Definition split.h:159
meta::ConnectResult< Send, SharedReceiver< Type > > Op
Definition split.h:112
Type(Send &&sender, A &&allocator_)
Definition split.h:115
StopSource & stop_source
Definition split.h:52
void operator()() const noexcept
Definition split.h:54
Definition completion_signuatures.h:7