Skip to content

Commit c25517a

Browse files
committed
implement execute in terms of start_detached
1 parent 9f7ecee commit c25517a

1 file changed

Lines changed: 3 additions & 23 deletions

File tree

include/stdexec/__detail/__execute.hpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,14 @@
2121
#include "__receivers.hpp"
2222
#include "__senders.hpp"
2323
#include "__schedulers.hpp"
24-
#include "__submit.hpp"
24+
#include "__start_detached.hpp"
25+
#include "__then.hpp"
2526
#include "__transform_sender.hpp"
2627

27-
#include <exception>
28-
2928
namespace stdexec {
3029
/////////////////////////////////////////////////////////////////////////////
3130
// [execution.execute]
3231
namespace __execute_ {
33-
template <class _Fun>
34-
struct __as_receiver {
35-
using receiver_concept = receiver_t;
36-
_Fun __fun_;
37-
38-
void set_value() noexcept {
39-
// terminates on exception:
40-
__fun_();
41-
}
42-
43-
[[noreturn]]
44-
void set_error(std::exception_ptr) noexcept {
45-
std::terminate();
46-
}
47-
48-
void set_stopped() noexcept {
49-
}
50-
};
51-
5232
struct execute_t {
5333
template <scheduler _Scheduler, class _Fun>
5434
requires __callable<_Fun&> && move_constructible<_Fun>
@@ -61,7 +41,7 @@ namespace stdexec {
6141
template <sender_of<set_value_t()> _Sender, class _Fun>
6242
requires __callable<_Fun&> && move_constructible<_Fun>
6343
void apply_sender(_Sender&& __sndr, _Fun __fun) const noexcept(false) {
64-
__submit(static_cast<_Sender&&>(__sndr), __as_receiver<_Fun>{static_cast<_Fun&&>(__fun)});
44+
start_detached(then(static_cast<_Sender&&>(__sndr), static_cast<_Fun&&>(__fun)));
6545
}
6646
};
6747
} // namespace __execute_

0 commit comments

Comments
 (0)