@@ -29,7 +29,6 @@ namespace exec::__system_context_default_impl {
2929 using namespace stdexec ::tags;
3030 using system_context_replaceability::receiver;
3131 using system_context_replaceability::bulk_item_receiver;
32- using system_context_replaceability::storage;
3332 using system_context_replaceability::parallel_scheduler_backend;
3433 using system_context_replaceability::__parallel_scheduler_backend_factory;
3534
@@ -104,17 +103,18 @@ namespace exec::__system_context_default_impl {
104103 };
105104
106105 // / Ensure that `__storage` is aligned to `__alignment`. Shrinks the storage, if needed, to match desired alignment.
107- inline storage __ensure_alignment (storage __storage, size_t __alignment) noexcept {
108- auto __pn = reinterpret_cast <uintptr_t >(__storage.__data );
106+ inline std::span<std::byte>
107+ __ensure_alignment (std::span<std::byte> __storage, size_t __alignment) noexcept {
108+ auto __pn = reinterpret_cast <uintptr_t >(__storage.data ());
109109 if (__pn % __alignment == 0 ) {
110110 return __storage;
111- } else if (__storage.__size < __alignment) {
112- return {nullptr , 0 };
111+ } else if (__storage.size () < __alignment) {
112+ return {};
113113 } else {
114114 auto __new_pn = (__pn + __alignment - 1 ) & ~(__alignment - 1 );
115115 return {
116- reinterpret_cast <void *>(__new_pn),
117- static_cast <uint32_t >(__storage.__size - (__new_pn - __pn))};
116+ reinterpret_cast <std::byte *>(__new_pn),
117+ static_cast <size_t >(__storage.size () - (__new_pn - __pn))};
118118 }
119119 }
120120
@@ -126,13 +126,15 @@ namespace exec::__system_context_default_impl {
126126 bool __on_heap_;
127127
128128 // / Try to construct the operation in the preallocated memory if it fits, otherwise allocate a new operation.
129- static __operation*
130- __construct_maybe_alloc (storage __storage, receiver* __completion, _Sender __sndr) {
129+ static __operation* __construct_maybe_alloc (
130+ std::span<std::byte> __storage,
131+ receiver* __completion,
132+ _Sender __sndr) {
131133 __storage = __ensure_alignment (__storage, alignof (__operation));
132- if (__storage.__data == nullptr || __storage.__size < sizeof (__operation)) {
134+ if (__storage.data () == nullptr || __storage.size () < sizeof (__operation)) {
133135 return new __operation (std::move (__sndr), __completion, true );
134136 } else {
135- return new (__storage.__data ) __operation (std::move (__sndr), __completion, false );
137+ return new (__storage.data () ) __operation (std::move (__sndr), __completion, false );
136138 }
137139 }
138140
@@ -174,7 +176,7 @@ namespace exec::__system_context_default_impl {
174176 bulk_item_receiver* __r_;
175177
176178 void operator ()(unsigned long __idx) const noexcept {
177- __r_->start (static_cast <uint32_t >(__idx));
179+ __r_->execute (static_cast <uint32_t >(__idx));
178180 }
179181 };
180182
@@ -187,27 +189,29 @@ namespace exec::__system_context_default_impl {
187189 std::declval<__bulk_functor>()))>;
188190
189191 public:
190- void schedule (storage __storage, receiver* __r) noexcept override {
192+ void schedule (std::span<std::byte> __storage, receiver& __r) noexcept override {
191193 try {
192194 auto __sndr = stdexec::schedule (__pool_scheduler_);
193195 auto __os =
194- __schedule_operation_t::__construct_maybe_alloc (__storage, __r, std::move (__sndr));
196+ __schedule_operation_t::__construct_maybe_alloc (__storage, & __r, std::move (__sndr));
195197 __os->start ();
196198 } catch (std::exception& __e) {
197- __r-> set_error (std::current_exception ());
199+ __r. set_error (std::current_exception ());
198200 }
199201 }
200202
201- void
202- bulk_schedule (uint32_t __size, storage __storage, bulk_item_receiver* __r) noexcept override {
203+ void bulk_schedule (
204+ uint32_t __size,
205+ std::span<std::byte> __storage,
206+ bulk_item_receiver& __r) noexcept override {
203207 try {
204208 auto __sndr =
205- stdexec::bulk (stdexec::schedule (__pool_scheduler_), __size, __bulk_functor{__r});
209+ stdexec::bulk (stdexec::schedule (__pool_scheduler_), __size, __bulk_functor{& __r});
206210 auto __os =
207- __bulk_schedule_operation_t::__construct_maybe_alloc (__storage, __r, std::move (__sndr));
211+ __bulk_schedule_operation_t::__construct_maybe_alloc (__storage, & __r, std::move (__sndr));
208212 __os->start ();
209213 } catch (std::exception& __e) {
210- __r-> set_error (std::current_exception ());
214+ __r. set_error (std::current_exception ());
211215 }
212216 }
213217 };
0 commit comments