|
20 | 20 | #include "__execution_fwd.hpp" |
21 | 21 |
|
22 | 22 | // include these after __execution_fwd.hpp |
23 | | -// #include "any_allocator.cuh" |
24 | 23 | #include "../functional.hpp" // IWYU pragma: keep for __with_default |
25 | 24 | #include "../stop_token.hpp" // IWYU pragma: keep for get_stop_token_t |
26 | 25 | #include "__any_allocator.hpp" |
@@ -83,28 +82,47 @@ namespace STDEXEC { |
83 | 82 | virtual void execute(size_t, size_t) noexcept = 0; |
84 | 83 | }; |
85 | 84 |
|
86 | | - /// Interface for the parallel scheduler backend. |
87 | | - struct parallel_scheduler_backend { |
88 | | - virtual ~parallel_scheduler_backend() = 0; |
89 | | - |
90 | | - /// Schedule work on parallel scheduler, calling `__r` when done and using `__s` for preallocated |
91 | | - /// memory. |
92 | | - virtual void schedule(receiver_proxy&, std::span<std::byte>) noexcept = 0; |
93 | | - |
94 | | - /// Schedule bulk work of size `__n` on parallel scheduler, calling `__r` for different |
95 | | - /// subranges of [0, __n), and using `__s` for preallocated memory. |
96 | | - virtual void |
97 | | - schedule_bulk_chunked(size_t, bulk_item_receiver_proxy&, std::span<std::byte>) noexcept = 0; |
98 | | - |
99 | | - /// Schedule bulk work of size `__n` on parallel scheduler, calling `__r` for each item, and |
100 | | - /// using `__s` for preallocated memory. |
101 | | - virtual void schedule_bulk_unchunked( |
102 | | - size_t, |
103 | | - bulk_item_receiver_proxy&, |
104 | | - std::span<std::byte>) noexcept = 0; |
| 85 | + // This base class associates the STDEXEC::system_context_replaceability namespace |
| 86 | + // with the parallel_scheduler_backend for the purposes of ADL. |
| 87 | + struct __parallel_scheduler_backend_base { |
| 88 | + virtual ~__parallel_scheduler_backend_base() = 0; |
105 | 89 | }; |
106 | 90 |
|
107 | | - inline parallel_scheduler_backend::~parallel_scheduler_backend() = default; |
| 91 | + inline __parallel_scheduler_backend_base::~__parallel_scheduler_backend_base() = default; |
| 92 | + } // namespace system_context_replaceability |
| 93 | +} // namespace STDEXEC |
| 94 | + |
| 95 | +// Give parallel_scheduler_backend a mangled name that does not depend on the value of the |
| 96 | +// STDEXEC macro. This is so that we can use weak linking to make |
| 97 | +// query_parallel_scheduler_backend replaceable. |
| 98 | +namespace __system_context_replaceability { |
| 99 | + using namespace STDEXEC::system_context_replaceability; |
| 100 | + |
| 101 | + /// Interface for the parallel scheduler backend. |
| 102 | + struct parallel_scheduler_backend : __parallel_scheduler_backend_base { |
| 103 | + /// Schedule work on parallel scheduler, calling `__r` when done and using `__s` for preallocated |
| 104 | + /// memory. |
| 105 | + virtual void schedule(receiver_proxy&, std::span<std::byte>) noexcept = 0; |
| 106 | + |
| 107 | + /// Schedule bulk work of size `__n` on parallel scheduler, calling `__r` for different |
| 108 | + /// subranges of [0, __n), and using `__s` for preallocated memory. |
| 109 | + virtual void schedule_bulk_chunked( |
| 110 | + std::size_t, |
| 111 | + bulk_item_receiver_proxy&, |
| 112 | + std::span<std::byte>) noexcept = 0; |
| 113 | + |
| 114 | + /// Schedule bulk work of size `__n` on parallel scheduler, calling `__r` for each item, and |
| 115 | + /// using `__s` for preallocated memory. |
| 116 | + virtual void schedule_bulk_unchunked( |
| 117 | + std::size_t, |
| 118 | + bulk_item_receiver_proxy&, |
| 119 | + std::span<std::byte>) noexcept = 0; |
| 120 | + }; |
| 121 | +} // namespace __system_context_replaceability |
| 122 | + |
| 123 | +namespace STDEXEC { |
| 124 | + namespace system_context_replaceability { |
| 125 | + using namespace ::__system_context_replaceability; |
108 | 126 | } // namespace system_context_replaceability |
109 | 127 |
|
110 | 128 | namespace __detail { |
|
0 commit comments