Skip to content

Commit 110d826

Browse files
authored
Move test::inline_scheduler to namespace beman::execution (#234)
1 parent 9e727c5 commit 110d826

File tree

8 files changed

+101
-60
lines changed

8 files changed

+101
-60
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ CMakeUserPresets.json
3535
*.app
3636

3737
build
38+
cmake-build-*
3839
.DS_store
3940
.vs
4041
.cache
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// include/beman/execution/detail/inline_scheduler.hpp -*-C++-*-
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#ifndef INCLUDED_BEMAN_DETAIL_EXECUTION_INLINE_SCHEDULER
5+
#define INCLUDED_BEMAN_DETAIL_EXECUTION_INLINE_SCHEDULER
6+
7+
// ----------------------------------------------------------------------------
8+
#include <beman/execution/detail/common.hpp>
9+
#ifdef BEMAN_HAS_IMPORT_STD
10+
import std;
11+
#else
12+
#include <type_traits>
13+
#include <utility>
14+
#endif
15+
#ifdef BEMAN_HAS_MODULES
16+
import beman.execution.detail.get_completion_scheduler;
17+
import beman.execution.detail.sender;
18+
import beman.execution.detail.receiver;
19+
import beman.execution.detail.set_value;
20+
import beman.execution.detail.operation_state;
21+
import beman.execution.detail.scheduler;
22+
import beman.execution.detail.scheduler_t;
23+
import beman.execution.detail.completion_signatures;
24+
#else
25+
#include <beman/execution/detail/get_completion_scheduler.hpp>
26+
#include <beman/execution/detail/sender.hpp>
27+
#include <beman/execution/detail/receiver.hpp>
28+
#include <beman/execution/detail/set_value.hpp>
29+
#include <beman/execution/detail/operation_state.hpp>
30+
#include <beman/execution/detail/scheduler.hpp>
31+
#include <beman/execution/detail/completion_signatures.hpp>
32+
#endif
33+
34+
namespace beman::execution {
35+
struct inline_scheduler {
36+
using scheduler_concept = ::beman::execution::scheduler_t;
37+
38+
struct env {
39+
static auto
40+
query(const ::beman::execution::get_completion_scheduler_t<::beman::execution::set_value_t>&) noexcept
41+
-> inline_scheduler {
42+
return {};
43+
}
44+
};
45+
46+
template <::beman::execution::receiver Rcvr>
47+
struct state {
48+
using operation_state_concept = ::beman::execution::operation_state_t;
49+
::std::remove_cvref_t<Rcvr> rcvr;
50+
auto start() & noexcept -> void { ::beman::execution::set_value(::std::move(rcvr)); }
51+
};
52+
53+
struct sender {
54+
using sender_concept = ::beman::execution::sender_t;
55+
using completion_signatures = ::beman::execution::completion_signatures<::beman::execution::set_value_t()>;
56+
57+
static constexpr auto get_env() noexcept -> env { return {}; }
58+
59+
template <typename, typename...>
60+
static consteval auto get_completion_signatures() noexcept -> completion_signatures {
61+
return {};
62+
}
63+
64+
template <::beman::execution::receiver Rcvr>
65+
auto connect(Rcvr&& receiver) noexcept(::std::is_nothrow_constructible_v<::std::remove_cvref_t<Rcvr>, Rcvr>)
66+
-> state<Rcvr> {
67+
return {::std::forward<Rcvr>(receiver)};
68+
}
69+
};
70+
71+
static constexpr auto schedule() noexcept -> sender { return {}; }
72+
73+
auto operator==(const inline_scheduler&) const -> bool = default;
74+
};
75+
} // namespace beman::execution
76+
77+
// ----------------------------------------------------------------------------
78+
79+
#endif // INCLUDED_BEMAN_DETAIL_EXECUTION_INLINE_SCHEDULER

src/beman/execution/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ target_sources(
9797
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/impls_for.hpp
9898
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/indices_for.hpp
9999
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/indirect_meta_apply.hpp
100+
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/inline_scheduler.hpp
100101
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/inplace_stop_source.hpp
101102
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/into_variant.hpp
102103
${PROJECT_SOURCE_DIR}/include/beman/execution/detail/intrusive_stack.hpp
@@ -282,6 +283,7 @@ if(BEMAN_USE_MODULES)
282283
impls_for.cppm
283284
indices_for.cppm
284285
indirect_meta_apply.cppm
286+
inline_scheduler.cppm
285287
inplace_stop_source.cppm
286288
into_variant.cppm
287289
intrusive_stack.cppm

src/beman/execution/execution.cppm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import beman.execution.detail.when_all;
7777
import beman.execution.detail.when_all_with_variant;
7878
export import beman.execution.detail.with_awaitable_senders; // [exec.with.awaitable.senders]
7979
import beman.execution.detail.write_env;
80+
import beman.execution.detail.inline_scheduler;
8081

8182
// [stoptoken.concepts], stop token concepts
8283
export import beman.execution.detail.stoppable_token;
@@ -254,6 +255,9 @@ export using ::beman::execution::counting_scope;
254255
export using ::beman::execution::spawn;
255256
export using ::beman::execution::spawn_future;
256257

258+
// [exec.inline.scheduler]
259+
export using ::beman::execution::inline_scheduler;
260+
257261
#if 0
258262
namespace detail {
259263
export using ::beman::execution::detail::await_result_type;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module;
2+
// src/beman/execution/inline_scheduler.cppm -*-C++-*-
3+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
#include <beman/execution/detail/inline_scheduler.hpp>
6+
7+
export module beman.execution.detail.inline_scheduler;
8+
9+
namespace beman::execution {
10+
export using beman::execution::inline_scheduler;
11+
} // namespace beman::execution

tests/beman/execution/exec-scope-counting.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <concepts>
55
#include <tuple>
66
#include <type_traits>
7-
#include <test/inline_scheduler.hpp>
87
#include <test/execution.hpp>
98
#ifdef BEMAN_HAS_MODULES
109
import beman.execution;
@@ -13,6 +12,7 @@ import beman.execution;
1312
#include <beman/execution/detail/sender.hpp>
1413
#include <beman/execution/detail/just.hpp>
1514
#include <beman/execution/detail/sync_wait.hpp>
15+
#include <beman/execution/detail/inline_scheduler.hpp>
1616
#endif
1717

1818
// ----------------------------------------------------------------------------
@@ -45,7 +45,7 @@ struct join_receiver {
4545
using receiver_concept = test_std::receiver_t;
4646

4747
struct env {
48-
auto query(const test_std::get_scheduler_t&) const noexcept -> test::inline_scheduler { return {}; }
48+
auto query(const test_std::get_scheduler_t&) const noexcept -> test_std::inline_scheduler { return {}; }
4949
};
5050

5151
bool& called;

tests/beman/execution/exec-scope-simple-counting.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <concepts>
55
#include <tuple>
66
#include <type_traits>
7-
#include <test/inline_scheduler.hpp>
87
#include <test/execution.hpp>
98
#ifdef BEMAN_HAS_MODULES
109
import beman.execution;
@@ -13,6 +12,7 @@ import beman.execution;
1312
#include <beman/execution/detail/sender.hpp>
1413
#include <beman/execution/detail/just.hpp>
1514
#include <beman/execution/detail/sync_wait.hpp>
15+
#include <beman/execution/detail/inline_scheduler.hpp>
1616
#endif
1717

1818
// ----------------------------------------------------------------------------
@@ -42,7 +42,7 @@ struct join_receiver {
4242
using receiver_concept = test_std::receiver_t;
4343

4444
struct env {
45-
auto query(const test_std::get_scheduler_t&) const noexcept -> test::inline_scheduler { return {}; }
45+
auto query(const test_std::get_scheduler_t&) const noexcept -> test_std::inline_scheduler { return {}; }
4646
};
4747

4848
bool& called;

tests/beman/execution/include/test/inline_scheduler.hpp

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)