54 template<
typename... Values>
60 template<
typename Seq>
69 template<
typename SharedState>
76 template<
typename... Args>
78 self.state->complete_with(
set_value, util::forward<Args>(values)...);
83 self.state->complete_with(
set_error, util::forward<E>(error));
94 template<
typename SharedState>
97 template<
typename Send,
typename SenderAttr,
typename Alloc>
116 explicit Type(Send&& sender, A&& allocator_)
121 auto* pointer =
this;
126 ,
allocator(util::forward<A>(allocator_))
131 template<
typename... Args>
156 template<
typename Send,
typename SenderAttr,
typename Alloc>
159 template<
typename Send,
typename Rec,
typename SenderAttr,
typename Alloc>
165 explicit Type(
State* state, Rec receiver) : m_state(state), m_receiver(
util::forward<Rec>(receiver)) {}
170 m_state->finish_one(
true);
176 self.m_started =
true;
178 auto completion_callback = [&self] {
180 self.m_stop_callback.reset();
183 auto& state = *self.m_state;
187 [&](
auto tag,
auto&&... values) {
190 util::forward<
decltype(values)>(values)...);
193 util::forward<
decltype(values)>(values)...);
198 util::forward<decltype(tuple)>(tuple));
200 util::move(state.storage));
204 auto allocator = util::move(state.allocator);
205 auto* pointer = util::addressof(state);
211 auto& state = *self.m_state;
213 state.did_complete = completion_callback;
214 return state.finish_one();
222 if (state.stop_source.stop_requested()) {
224 return state.finish_one();
228 state.did_complete = completion_callback;
236 bool m_started {
false };
240 template<
typename Send,
typename Rec,
typename SenderAttr,
typename Alloc>
243 template<
typename Send,
typename Alloc>
260 state->finish_one(
true);
270 template<concepts::ReceiverOf<CompletionSignatures> Rec>
274 util::move(receiver));
279 return self.m_state->sender_attr;
282 State* m_state {
nullptr };
286 template<
typename Send,
typename Alloc>
290 template<concepts::SenderIn<Env> Send, concepts::Allocator Alloc = platform::DefaultAllocator>
292 auto operator()(Send&& sender, Alloc&& allocator = {})
const {
293 if constexpr (
requires {
295 util::forward<Send>(sender), util::forward<Alloc>(allocator));
298 util::forward<Send>(sender), util::forward<Alloc>(allocator));
299 }
else if constexpr (
requires {
300 tag_invoke(*
this, util::forward<Send>(sender), util::forward<Alloc>(allocator));
302 return tag_invoke(*
this, util::forward<Send>(sender), util::forward<Alloc>(allocator));
306 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
Definition ensure_started.h:43
meta::Decay< T > && DecayedRValue
Definition ensure_started.h:50
meta::Type< SenderT< Send, meta::Decay< Alloc > > > Sender
Definition ensure_started.h:287
meta::Type< SharedReceiverT< SharedState > > SharedReceiver
Definition ensure_started.h:95
meta::Type< OperationStateT< Send, Rec, meta::Decay< SenderAttr >, Alloc > > OperationState
Definition ensure_started.h:241
MakeEnv< EmptyEnv, With< Tag< get_stop_token >, StopToken > > Env
Definition ensure_started.h:52
CompletionSignatures< SetError(meta::Decay< E > &&)> SigSetError
Definition ensure_started.h:58
meta::Type< SharedStateT< Send, meta::Decay< SenderAttr >, meta::Decay< Alloc > > > SharedState
Definition ensure_started.h:157
CompletionSignatures< SetValue(meta::Decay< Values > &&...)> SigSetValue
Definition ensure_started.h:55
meta::MakeCompletionSignatures< Seq, Env, CompletionSignatures<>, SigSetValue, SigSetError > Sigs
Definition ensure_started.h:61
sync::InPlaceStopSource StopSource
Definition ensure_started.h:46
sync::InPlaceStopToken StopToken
Definition ensure_started.h:47
constexpr auto set_error
Definition set_error.h:14
constexpr auto ensure_started
Eagerly start a sender.
Definition ensure_started.h:333
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 request_stop
Request that a scope stop.
Definition scope.h:48
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 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
@ Relaxed
Definition memory_order.h:7
@ AcquireRelease
Definition memory_order.h:11
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 empty_env
Definition empty_env.h:6
Definition set_stopped.h:6
Definition ensure_started.h:289
Type(State *state, Rec receiver)
Definition ensure_started.h:165
~Type()
Definition ensure_started.h:167
friend void tag_invoke(Tag< start >, Type &self)
Definition ensure_started.h:175
SharedState< Send, SenderAttr, Alloc > State
Definition ensure_started.h:163
Definition ensure_started.h:160
void is_sender
Definition ensure_started.h:247
~Type()
Definition ensure_started.h:257
auto operator=(Type &&other) -> Type &
Definition ensure_started.h:264
Sigs< Send > CompletionSignatures
Definition ensure_started.h:249
Type(State *state)
Definition ensure_started.h:253
Type(Type &&other)
Definition ensure_started.h:255
SharedState< Send, meta::EnvOf< Send >, Alloc > State
Definition ensure_started.h:251
friend auto tag_invoke(Tag< connect >, Type &&self, Rec receiver)
Definition ensure_started.h:271
friend auto tag_invoke(Tag< get_env >, Type const &self) -> meta::Decay< meta::EnvOf< Send > > const &
Definition ensure_started.h:277
Definition ensure_started.h:244
Definition ensure_started.h:71
friend void tag_invoke(Tag< set_error >, Type &&self, E &&error)
Definition ensure_started.h:82
friend void tag_invoke(Tag< set_stopped >, Type &&self)
Definition ensure_started.h:86
friend auto tag_invoke(Tag< get_env >, Type const &self) -> Env
Definition ensure_started.h:88
void is_receiver
Definition ensure_started.h:72
friend void tag_invoke(Tag< set_value >, Type &&self, Args &&... values)
Definition ensure_started.h:77
SharedState * state
Definition ensure_started.h:74
Definition ensure_started.h:70
sync::Atomic< usize > ref_count
Definition ensure_started.h:150
meta::Transform< Completions, meta::Compose< meta::Quote< meta::List >, meta::Quote< meta::LanguageFunctionReturn > > > Tags
Definition ensure_started.h:101
Alloc allocator
Definition ensure_started.h:151
Type(Send &&sender, A &&allocator_)
Definition ensure_started.h:116
Storage storage
Definition ensure_started.h:147
DI_IMMOVABLE_NO_UNIQUE_ADDRESS Op operation
Definition ensure_started.h:152
void complete_with(Args &&... args)
Definition ensure_started.h:132
Function< void()> did_complete
Definition ensure_started.h:146
meta::AsTemplate< vocab::Variant, meta::PushFront< meta::Unique< meta::Transform< meta::Zip< Tags, DecayedArgs >, meta::Compose< meta::Uncurry< meta::Quote< meta::DecayedTuple > >, meta::Quote< meta::Join > > > >, vocab::Tuple< Void > > > Storage
Definition ensure_started.h:105
void finish_one(bool request_stop=false)
Definition ensure_started.h:137
meta::AsList< meta::CompletionSignaturesOf< Send, Env > > Completions
Definition ensure_started.h:100
SenderAttr sender_attr
Definition ensure_started.h:149
meta::Transform< Completions, meta::Quote< meta::AsList > > DecayedArgs
Definition ensure_started.h:104
StopSource stop_source
Definition ensure_started.h:148
meta::ConnectResult< Send, SharedReceiver< Type > > Op
Definition ensure_started.h:113
Definition ensure_started.h:98
Definition ensure_started.h:63
void operator()() const noexcept
Definition ensure_started.h:66
StopSource & stop_source
Definition ensure_started.h:64
Definition completion_signuatures.h:7