Skip to content

Commit

Permalink
Rename continue_on and start_on to continues_on and starts_on
Browse files Browse the repository at this point in the history
… with deprecation warnings (#1415)

* Rename continue_on to continues_on with deprecation warnings

* Rename start_on to starts_on with deprecation warnings

* Use renamed continues_on/starts_on in tests and examples

* Rename internal __continue_on_data to __on_data used by on adaptor

* Use continues_on instead of transfer in nvexec

---------

Co-authored-by: Eric Niebler <eniebler@nvidia.com>
  • Loading branch information
msimberg and ericniebler authored Sep 19, 2024
1 parent 4feb2ed commit 0ce265a
Show file tree
Hide file tree
Showing 55 changed files with 375 additions and 342 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ int main()
// represents the work to later be executed
auto fun = [](int i) { return i*i; };
auto work = stdexec::when_all(
stdexec::on(sched, stdexec::just(0) | stdexec::then(fun)),
stdexec::on(sched, stdexec::just(1) | stdexec::then(fun)),
stdexec::on(sched, stdexec::just(2) | stdexec::then(fun))
stdexec::starts_on(sched, stdexec::just(0) | stdexec::then(fun)),
stdexec::starts_on(sched, stdexec::just(1) | stdexec::then(fun)),
stdexec::starts_on(sched, stdexec::just(2) | stdexec::then(fun))
);

// Launch the work and wait for the result
Expand Down
2 changes: 1 addition & 1 deletion examples/benchmark/fibonacci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct fib_s {
stdexec::set_value(static_cast<Receiver&&>(self.rcvr_), serial_fib(self.n));
} else {
auto mkchild = [&](long n) {
return stdexec::on(self.sched, fib_sender(fib_s{self.cutoff, n, self.sched}));
return stdexec::starts_on(self.sched, fib_sender(fib_s{self.cutoff, n, self.sched}));
};

stdexec::start_detached(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct RunThread {
auto [start, end] = exec::_pool_::even_share(total_scheds, tid, pool.available_parallelism());
auto iterate = exec::iterate(std::views::iota(start, end)) | exec::ignore_all_values();
# endif
stdexec::sync_wait(stdexec::on(scheduler, iterate));
stdexec::sync_wait(stdexec::starts_on(scheduler, iterate));
barrier.arrive_and_wait();
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ int main() {
(void) t;

auto y = let_value(get_scheduler(), [](auto sched) {
return on(sched, then(just(), [] {
std::cout << "from run_loop\n";
return 42;
}));
return starts_on(sched, then(just(), [] {
std::cout << "from run_loop\n";
return 42;
}));
});
sync_wait(std::move(y));

Expand Down
2 changes: 1 addition & 1 deletion examples/scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main() {
sender auto printVoid = then(begin, []() noexcept { printf("void\n"); }); // 3
//
sender auto printEmpty = then(
on(sch, scope.on_empty()),
starts_on(sch, scope.on_empty()),
[]() noexcept { // 4
printf("scope is empty\n"); //
}); //
Expand Down
6 changes: 3 additions & 3 deletions examples/server_theme/on_transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* Example goals:
* - show how one can change the execution context
* - exemplify the use of `on` and `transfer` algorithms
* - exemplify the use of `starts_on` and `continues_on` algorithms
*/

#include <iostream>
Expand Down Expand Up @@ -103,9 +103,9 @@ int main() {
// The entire flow
auto snd =
// start by reading data on the I/O thread
ex::on(io_sched, std::move(snd_read))
ex::starts_on(io_sched, std::move(snd_read))
// do the processing on the worker threads pool
| ex::transfer(work_sched)
| ex::continues_on(work_sched)
// process the incoming data (on worker threads)
| ex::then([buf](size_t read_len) { process_read_data(buf, read_len); })
// done
Expand Down
4 changes: 2 additions & 2 deletions examples/server_theme/split_bulk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int main() {
<< resp.body_ << "\n";
std::cout << oss.str();
});
scope.spawn(ex::on(sched, std::move(action)));
scope.spawn(ex::starts_on(sched, std::move(action)));
}

// Fake a couple of multi_blur requests
Expand All @@ -206,7 +206,7 @@ int main() {
<< resp.body_ << "\n";
std::cout << oss.str();
});
scope.spawn(ex::on(sched, std::move(action)));
scope.spawn(ex::starts_on(sched, std::move(action)));
}

stdexec::sync_wait(scope.on_empty());
Expand Down
2 changes: 1 addition & 1 deletion examples/server_theme/then_upon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int main() {
<< resp.body_ << "\n";
std::cout << oss.str();
});
scope.spawn(ex::on(sched, std::move(action)));
scope.spawn(ex::starts_on(sched, std::move(action)));
}

stdexec::sync_wait(scope.on_empty());
Expand Down
5 changes: 3 additions & 2 deletions include/exec/repeat_effect_until.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ namespace exec {
__enable_receiver_from_this<_Sender, _Receiver, __repeat_effect_state<_Sender, _Receiver>> {
using __child_t = __decay_t<__data_of<_Sender>>;
using __receiver_t = stdexec::__t<__receiver<__id<_Sender>, __id<_Receiver>>>;
using __child_on_sched_sender_t = __result_of<stdexec::on, trampoline_scheduler, __child_t &>;
using __child_on_sched_sender_t =
__result_of<stdexec::starts_on, trampoline_scheduler, __child_t &>;
using __child_op_t = stdexec::connect_result_t<__child_on_sched_sender_t, __receiver_t>;

__child_t __child_;
Expand All @@ -103,7 +104,7 @@ namespace exec {

void __connect() {
__child_op_.__construct_from([this] {
return stdexec::connect(stdexec::on(__sched_, __child_), __receiver_t{this});
return stdexec::connect(stdexec::starts_on(__sched_, __child_), __receiver_t{this});
});
}

Expand Down
6 changes: 4 additions & 2 deletions include/exec/repeat_n.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ namespace exec {
using __child_count_pair_t = __decay_t<__data_of<_Sender>>;
using __child_t = decltype(__child_count_pair_t::__child_);
using __receiver_t = stdexec::__t<__receiver<__id<_Sender>, __id<_Receiver>>>;
using __child_on_sched_sender_t = __result_of<stdexec::on, trampoline_scheduler, __child_t &>;
using __child_on_sched_sender_t =
__result_of<stdexec::starts_on, trampoline_scheduler, __child_t &>;
using __child_op_t = stdexec::connect_result_t<__child_on_sched_sender_t, __receiver_t>;

__child_count_pair<__child_t> __pair_;
Expand All @@ -115,7 +116,8 @@ namespace exec {

void __connect() {
__child_op_.__construct_from([this] {
return stdexec::connect(stdexec::on(__sched_, __pair_.__child_), __receiver_t{this});
return stdexec::connect(
stdexec::starts_on(__sched_, __pair_.__child_), __receiver_t{this});
});
}

Expand Down
4 changes: 2 additions & 2 deletions include/exec/reschedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ namespace exec {
struct __reschedule_t {
template <sender _Sender>
auto operator()(_Sender&& __sndr) const {
return stdexec::transfer(static_cast<_Sender&&>(__sndr), __resched::__scheduler{});
return stdexec::continues_on(static_cast<_Sender&&>(__sndr), __resched::__scheduler{});
}

auto operator()() const {
return stdexec::transfer(__resched::__scheduler{});
return stdexec::continues_on(__resched::__scheduler{});
}
};
} // namespace __resched
Expand Down
6 changes: 3 additions & 3 deletions include/exec/sequence/iterate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace exec {
using _Receiver = stdexec::__t<_ReceiverId>;
_Receiver __rcvr_;

using _ItemSender = decltype(stdexec::on(
using _ItemSender = decltype(stdexec::starts_on(
std::declval<trampoline_scheduler&>(),
std::declval<__sender_t<_Range>>()));

Expand All @@ -132,7 +132,7 @@ namespace exec {
try {
stdexec::start(__op_.emplace(__emplace_from{[&] {
return stdexec::connect(
exec::set_next(__rcvr_, stdexec::on(__scheduler_, __sender_t<_Range>{this})),
exec::set_next(__rcvr_, stdexec::starts_on(__scheduler_, __sender_t<_Range>{this})),
__next_receiver_t{this});
}}));
} catch (...) {
Expand Down Expand Up @@ -176,7 +176,7 @@ namespace exec {


template <class _Sequence>
using _ItemSender = decltype(stdexec::on(
using _ItemSender = decltype(stdexec::starts_on(
__declval<trampoline_scheduler&>(),
__declval<__sender_t<__data_of<_Sequence>>>()));

Expand Down
3 changes: 2 additions & 1 deletion include/exec/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ namespace exec {
// TODO: If we have a complete-where-it-starts query then we can optimize
// this to avoid the reschedule
return as_awaitable(
transfer(static_cast<_Awaitable&&>(__awaitable), get_scheduler(*__context_)), *this);
continues_on(static_cast<_Awaitable&&>(__awaitable), get_scheduler(*__context_)),
*this);
}

template <class _Scheduler>
Expand Down
2 changes: 1 addition & 1 deletion include/nvexec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- [x] `let_error`
- [x] `let_stopped`
- [x] `schedule_from`
- [x] `transfer`
- [x] `continues_on`
- [x] `sync_wait`
- [x] `ensure_started`
- [x] `start_detached`
Expand Down
4 changes: 2 additions & 2 deletions include/nvexec/multi_gpu_context.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ namespace nvexec {
}

template <sender S, scheduler Sch>
STDEXEC_MEMFN_DECL(auto transfer)(
STDEXEC_MEMFN_DECL(auto continues_on)(
this const multi_gpu_stream_scheduler& sch, //
S&& sndr, //
Sch&& scheduler) noexcept {
return schedule_from(
static_cast<Sch&&>(scheduler),
transfer_sender_th<S>(sch.context_state_, static_cast<S&&>(sndr)));
continues_on_sender_th<S>(sch.context_state_, static_cast<S&&>(sndr)));
}

template <sender S>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace nvexec::STDEXEC_STREAM_DETAIL_NS {

namespace _transfer {
namespace _continues_on {
template <class CvrefSenderId, class ReceiverId>
struct operation_state_t {
using Sender = __cvref_t<CvrefSenderId>;
Expand Down Expand Up @@ -107,18 +107,19 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS {
STDEXEC_IMMOVABLE(__t);
};
};
} // namespace _transfer
} // namespace _continues_on

template <class SenderId>
struct transfer_sender_t {
struct continues_on_sender_t {
using Sender = stdexec::__t<SenderId>;

struct __t : stream_sender_base {
using __id = transfer_sender_t;
using __id = continues_on_sender_t;

template <class Self, class Receiver>
using op_state_th = //
stdexec::__t<_transfer::operation_state_t<__cvref_id<Self, Sender>, stdexec::__id<Receiver>>>;
stdexec::__t<
_continues_on::operation_state_t<__cvref_id<Self, Sender>, stdexec::__id<Receiver>>>;

context_state_t context_state_;
Sender sndr_;
Expand Down Expand Up @@ -147,7 +148,8 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS {
}

template <__decays_to<__t> Self, class... Env>
static auto get_completion_signatures(Self&&, Env&&...) -> _completion_signatures_t<Self, Env...> {
static auto
get_completion_signatures(Self&&, Env&&...) -> _completion_signatures_t<Self, Env...> {
return {};
}

Expand All @@ -166,6 +168,6 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS {
namespace stdexec::__detail {
template <class SenderId>
inline constexpr __mconst<
nvexec::STDEXEC_STREAM_DETAIL_NS::transfer_sender_t<__name_of<__t<SenderId>>>>
__name_of_v<nvexec::STDEXEC_STREAM_DETAIL_NS::transfer_sender_t<SenderId>>{};
nvexec::STDEXEC_STREAM_DETAIL_NS::continues_on_sender_t<__name_of<__t<SenderId>>>>
__name_of_v<nvexec::STDEXEC_STREAM_DETAIL_NS::continues_on_sender_t<SenderId>>{};
} // namespace stdexec::__detail
13 changes: 6 additions & 7 deletions include/nvexec/stream_context.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "stream/submit.cuh"
#include "stream/split.cuh"
#include "stream/then.cuh"
#include "stream/transfer.cuh"
#include "stream/continues_on.cuh"
#include "stream/launch.cuh"
#include "stream/upon_error.cuh"
#include "stream/upon_stopped.cuh"
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace nvexec {
using let_xxx_th = __t<let_sender_t<__id<__decay_t<Sender>>, Fun, Set>>;

template <sender Sender>
using transfer_sender_th = __t<transfer_sender_t<__id<__decay_t<Sender>>>>;
using continues_on_sender_th = __t<continues_on_sender_t<__id<__decay_t<Sender>>>>;

template <sender Sender>
using ensure_started_th = __t<ensure_started_sender_t<__id<Sender>>>;
Expand Down Expand Up @@ -162,8 +162,7 @@ namespace nvexec {
}

template <sender S>
STDEXEC_MEMFN_DECL(auto ensure_started)(this const stream_scheduler& sch, S&& sndr) noexcept
-> ensure_started_th<S> {
STDEXEC_MEMFN_DECL(auto ensure_started)(this const stream_scheduler& sch, S&& sndr) noexcept -> ensure_started_th<S> {
return ensure_started_th<S>(sch.context_state_, static_cast<S&&>(sndr));
}

Expand Down Expand Up @@ -216,11 +215,11 @@ namespace nvexec {
}

template <sender S, scheduler Sch>
STDEXEC_MEMFN_DECL(auto transfer)(this const stream_scheduler& sch, S&& sndr, Sch&& scheduler) //
noexcept -> __result_of<schedule_from, Sch, transfer_sender_th<S>> {
STDEXEC_MEMFN_DECL(auto continues_on)(this const stream_scheduler& sch, S&& sndr, Sch&& scheduler) //
noexcept -> __result_of<schedule_from, Sch, continues_on_sender_th<S>> {
return schedule_from(
static_cast<Sch&&>(scheduler),
transfer_sender_th<S>(sch.context_state_, static_cast<S&&>(sndr)));
continues_on_sender_th<S>(sch.context_state_, static_cast<S&&>(sndr)));
}

template <sender S>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

namespace stdexec {
/////////////////////////////////////////////////////////////////////////////
// [execution.senders.adaptors.continue_on]
namespace __continue_on {
// [execution.senders.adaptors.continues_on]
namespace __continues_on {
using __schfr::__environ;

template <class _Env>
Expand All @@ -46,22 +46,22 @@ namespace stdexec {
using __lowered_t = //
__result_of<schedule_from, __scheduler_t<__data_of<_Sender>>, __child_of<_Sender>>;

struct continue_on_t {
struct continues_on_t {
template <sender _Sender, scheduler _Scheduler>
auto operator()(_Sender&& __sndr, _Scheduler&& __sched) const -> __well_formed_sender auto {
auto __domain = __get_early_domain(__sndr);
using _Env = __t<__environ<__id<__decay_t<_Scheduler>>>>;
return stdexec::transform_sender(
__domain,
__make_sexpr<continue_on_t>(
__make_sexpr<continues_on_t>(
_Env{{static_cast<_Scheduler&&>(__sched)}}, static_cast<_Sender&&>(__sndr)));
}

template <scheduler _Scheduler>
STDEXEC_ATTRIBUTE((always_inline))
auto
operator()(_Scheduler&& __sched) const
-> __binder_back<continue_on_t, __decay_t<_Scheduler>> {
-> __binder_back<continues_on_t, __decay_t<_Scheduler>> {
return {{static_cast<_Scheduler&&>(__sched)}, {}, {}};
}

Expand All @@ -71,11 +71,11 @@ namespace stdexec {
using __legacy_customizations_t = //
__types<
tag_invoke_t(
continue_on_t,
continues_on_t,
get_completion_scheduler_t<set_value_t>(get_env_t(const _Sender&)),
_Sender,
get_completion_scheduler_t<set_value_t>(_Env)),
tag_invoke_t(continue_on_t, _Sender, get_completion_scheduler_t<set_value_t>(_Env))>;
tag_invoke_t(continues_on_t, _Sender, get_completion_scheduler_t<set_value_t>(_Env))>;

template <class _Env>
static auto __transform_sender_fn(const _Env&) {
Expand All @@ -91,7 +91,7 @@ namespace stdexec {
}
};

struct __continue_on_impl : __sexpr_defaults {
struct __continues_on_impl : __sexpr_defaults {
static constexpr auto get_attrs = //
[]<class _Data, class _Child>(const _Data& __data, const _Child& __child) noexcept
-> decltype(auto) {
Expand All @@ -104,14 +104,17 @@ namespace stdexec {
transform_sender_result_t<default_domain, _Sender, empty_env>> {
};
};
} // namespace __continue_on
} // namespace __continues_on

using __continue_on::continue_on_t;
inline constexpr continue_on_t continue_on{};
using __continues_on::continues_on_t;
inline constexpr continues_on_t continues_on{};

using transfer_t = continue_on_t;
inline constexpr transfer_t transfer{};
using transfer_t = continues_on_t;
inline constexpr continues_on_t transfer{};

using continue_on_t = continues_on_t;
inline constexpr continues_on_t continue_on{};

template <>
struct __sexpr_impl<continue_on_t> : __continue_on::__continue_on_impl { };
struct __sexpr_impl<continues_on_t> : __continues_on::__continues_on_impl { };
} // namespace stdexec
Loading

0 comments on commit 0ce265a

Please sign in to comment.