Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e1e20f

Browse files
authored
Merge pull request#1018 from NVIDIA/schedule-from-type-recursion
break type recursion in `schedule_from` implementation
2 parents0693876 +490fc8b commit1e1e20f

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

‎include/stdexec/execution.hpp‎

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4938,8 +4938,8 @@ namespace stdexec {
49384938
set_error_t,
49394939
set_stopped_t>>;
49404940

4941-
template<class_SchedulerId,class_CvrefSenderId,class_ReceiverId>
4942-
struct__operation1;
4941+
template<class_SchedulerId,class_Variant,class_ReceiverId>
4942+
struct__operation1_base;
49434943

49444944
// This receiver is to be completed on the execution context
49454945
// associated with the scheduler. When the source sender
@@ -4948,14 +4948,14 @@ namespace stdexec {
49484948
// read the completion out of the operation state and forward it
49494949
// to the output receiver after transitioning to the scheduler's
49504950
// context.
4951-
template<class_SchedulerId,class_CvrefSenderId,class_ReceiverId>
4951+
template<class_SchedulerId,class_Variant,class_ReceiverId>
49524952
struct__receiver2 {
49534953
using _Receiver = stdexec::__t<_ReceiverId>;
49544954

49554955
struct__t {
49564956
using is_receiver =void;
49574957
using __id = __receiver2;
4958-
stdexec::__t<__operation1<_SchedulerId,_CvrefSenderId, _ReceiverId>>* __op_state_;
4958+
__operation1_base<_SchedulerId,_Variant, _ReceiverId>* __op_state_;
49594959

49604960
// If the work is successfully scheduled on the new execution
49614961
// context and is ready to run, forward the completion signal in
@@ -4984,15 +4984,15 @@ namespace stdexec {
49844984
// context of the scheduler. That second receiver will read the
49854985
// completion information out of the operation state and propagate
49864986
// it to the output receiver from within the desired context.
4987-
template<class_SchedulerId,class_CvrefSenderId,class_ReceiverId>
4987+
template<class_SchedulerId,class_Variant,class_ReceiverId>
49884988
struct__receiver1 {
49894989
using _Scheduler = stdexec::__t<_SchedulerId>;
49904990
using _Receiver = stdexec::__t<_ReceiverId>;
4991-
using__receiver2_t = stdexec::__t<__receiver2<_SchedulerId,_CvrefSenderId, _ReceiverId>>;
4991+
using__receiver2_t = stdexec::__t<__receiver2<_SchedulerId,_Variant, _ReceiverId>>;
49924992

49934993
struct__t {
49944994
using is_receiver =void;
4995-
stdexec::__t<__operation1<_SchedulerId,_CvrefSenderId, _ReceiverId>>* __op_state_;
4995+
__operation1_base<_SchedulerId,_Variant, _ReceiverId>* __op_state_;
49964996

49974997
template<class... _Args>
49984998
staticconstexprbool __nothrow_complete_ = (__nothrow_decay_copyable<_Args> && ...);
@@ -5027,52 +5027,62 @@ namespace stdexec {
50275027
};
50285028
};
50295029

5030+
template<class_SchedulerId,class_Variant,class_ReceiverId>
5031+
struct__operation1_base : __immovable {
5032+
using _Scheduler = stdexec::__t<_SchedulerId>;
5033+
using _Receiver = stdexec::__t<_ReceiverId>;
5034+
using__receiver2_t = stdexec::__t<__receiver2<_SchedulerId, _Variant, _ReceiverId>>;
5035+
5036+
_Scheduler __sched_;
5037+
_Receiver __rcvr_;
5038+
_Variant __data_;
5039+
connect_result_t<schedule_result_t<_Scheduler>,__receiver2_t> __state2_;
5040+
5041+
__operation1_base(_Scheduler __sched, _Receiver&& __rcvr)
5042+
: __sched_((_Scheduler&&) __sched)
5043+
, __rcvr_((_Receiver&&) __rcvr)
5044+
, __state2_(connect(schedule(__sched_),__receiver2_t{this})) {
5045+
}
5046+
5047+
void__complete()noexcept {
5048+
STDEXEC_ASSERT(!__data_.valueless_by_exception());
5049+
std::visit(
5050+
[this]<class_Tup>(_Tup& __tupl) ->void {
5051+
ifconstexpr (same_as<_Tup, std::monostate>) {
5052+
std::terminate();// reaching this indicates a bug in schedule_from
5053+
}else {
5054+
std::apply(
5055+
[&]<class... _Args>(auto __tag, _Args&... __args) ->void {
5056+
__tag((_Receiver&&) __rcvr_, (_Args&&) __args...);
5057+
},
5058+
__tupl);
5059+
}
5060+
},
5061+
__data_);
5062+
}
5063+
};
5064+
50305065
template<class_SchedulerId,class_CvrefSenderId,class_ReceiverId>
50315066
struct__operation1 {
50325067
using _Scheduler = stdexec::__t<_SchedulerId>;
50335068
using _CvrefSender = stdexec::__cvref_t<_CvrefSenderId>;
50345069
using _Receiver = stdexec::__t<_ReceiverId>;
5035-
using__receiver1_t = stdexec::__t<__receiver1<_SchedulerId, _CvrefSenderId, _ReceiverId>>;
5036-
using__receiver2_t = stdexec::__t<__receiver2<_SchedulerId, _CvrefSenderId, _ReceiverId>>;
50375070
using__variant_t =__variant_for_t<_CvrefSender,env_of_t<_Receiver>>;
5071+
using__receiver1_t = stdexec::__t<__receiver1<_SchedulerId,__variant_t, _ReceiverId>>;
5072+
using__base_t = __operation1_base<_SchedulerId,__variant_t, _ReceiverId>;
50385073

5039-
struct__t {
5074+
struct__t:__base_t{
50405075
using __id = __operation1;
5041-
_Scheduler __sched_;
5042-
_Receiver __rcvr_;
5043-
__variant_t __data_;
50445076
connect_result_t<_CvrefSender,__receiver1_t> __state1_;
5045-
connect_result_t<schedule_result_t<_Scheduler>,__receiver2_t> __state2_;
50465077

50475078
__t(_Scheduler __sched, _CvrefSender&& __sndr, _Receiver&& __rcvr)
5048-
: __sched_((_Scheduler&&) __sched)
5049-
, __rcvr_((_Receiver&&) __rcvr)
5050-
, __state1_(connect((_CvrefSender&&) __sndr,__receiver1_t{this}))
5051-
, __state2_(connect(schedule(__sched_),__receiver2_t{this})) {
5079+
:__base_t{(_Scheduler&&) __sched, (_Receiver&&) __rcvr}
5080+
, __state1_(connect((_CvrefSender&&) __sndr,__receiver1_t{this})) {
50525081
}
50535082

5054-
STDEXEC_IMMOVABLE(__t);
5055-
50565083
friendvoidtag_invoke(start_t,__t& __op_state)noexcept {
50575084
start(__op_state.__state1_);
50585085
}
5059-
5060-
void__complete()noexcept {
5061-
STDEXEC_ASSERT(!__data_.valueless_by_exception());
5062-
std::visit(
5063-
[&]<class_Tup>(_Tup& __tupl) ->void {
5064-
ifconstexpr (same_as<_Tup, std::monostate>) {
5065-
std::terminate();// reaching this indicates a bug in schedule_from
5066-
}else {
5067-
std::apply(
5068-
[&]<class... _Args>(auto __tag, _Args&... __args) ->void {
5069-
__tag((_Receiver&&) __rcvr_, (_Args&&) __args...);
5070-
},
5071-
__tupl);
5072-
}
5073-
},
5074-
__data_);
5075-
}
50765086
};
50775087
};
50785088

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp