3333
3434namespace ex = stdexec;
3535
36- TEST_CASE (" system_context has default ctor and dtor" , " [types][system_scheduler]" ) {
37- STATIC_REQUIRE (std::is_default_constructible_v<exec::system_context>);
38- STATIC_REQUIRE (std::is_destructible_v<exec::system_context>);
39- }
40-
41- TEST_CASE (" system_context is not copyable nor movable" , " [types][system_scheduler]" ) {
42- STATIC_REQUIRE_FALSE (std::is_copy_constructible_v<exec::system_context>);
43- STATIC_REQUIRE_FALSE (std::is_move_constructible_v<exec::system_context>);
44- }
45-
4636TEST_CASE (" system_context can return a scheduler" , " [types][system_scheduler]" ) {
47- auto sched = exec::system_context{}. get_scheduler ();
37+ auto sched = exec::get_system_scheduler ();
4838 STATIC_REQUIRE (ex::scheduler<decltype (sched)>);
4939}
5040
51- TEST_CASE (" can query max concurrency from system_context" , " [types][system_scheduler]" ) {
52- exec::system_context ctx;
53- size_t max_concurrency = ctx.max_concurrency ();
54- REQUIRE (max_concurrency >= 1 );
55- }
56-
5741TEST_CASE (" system scheduler is not default constructible" , " [types][system_scheduler]" ) {
58- auto sched = exec::system_context{}. get_scheduler ();
42+ auto sched = exec::get_system_scheduler ();
5943 using sched_t = decltype (sched);
6044 STATIC_REQUIRE (!std::is_default_constructible_v<sched_t >);
6145 STATIC_REQUIRE (std::is_destructible_v<sched_t >);
6246}
6347
6448TEST_CASE (" system scheduler is copyable and movable" , " [types][system_scheduler]" ) {
65- auto sched = exec::system_context{}. get_scheduler ();
49+ auto sched = exec::get_system_scheduler ();
6650 using sched_t = decltype (sched);
6751 STATIC_REQUIRE (std::is_copy_constructible_v<sched_t >);
6852 STATIC_REQUIRE (std::is_move_constructible_v<sched_t >);
6953}
7054
7155TEST_CASE (" a copied scheduler is equal to the original" , " [types][system_scheduler]" ) {
72- exec::system_context ctx;
73- auto sched1 = ctx.get_scheduler ();
56+ auto sched1 = exec::get_system_scheduler ();
7457 auto sched2 = sched1;
7558 REQUIRE (sched1 == sched2);
7659}
7760
7861TEST_CASE (
79- " two schedulers obtained from the same system_context are equal" ,
80- " [types][system_scheduler]" ) {
81- exec::system_context ctx;
82- auto sched1 = ctx.get_scheduler ();
83- auto sched2 = ctx.get_scheduler ();
84- REQUIRE (sched1 == sched2);
85- }
86-
87- TEST_CASE (
88- " compare two schedulers obtained from different system_context objects" ,
62+ " two schedulers obtained from get_system_scheduler() are equal" ,
8963 " [types][system_scheduler]" ) {
90- exec::system_context ctx1;
91- auto sched1 = ctx1.get_scheduler ();
92- exec::system_context ctx2;
93- auto sched2 = ctx2.get_scheduler ();
94- // TODO: clarify the result of this in the paper
64+ auto sched1 = exec::get_system_scheduler ();
65+ auto sched2 = exec::get_system_scheduler ();
9566 REQUIRE (sched1 == sched2);
9667}
9768
9869TEST_CASE (" system scheduler can produce a sender" , " [types][system_scheduler]" ) {
99- auto snd = ex::schedule (exec::system_context{}. get_scheduler ());
70+ auto snd = ex::schedule (exec::get_system_scheduler ());
10071 using sender_t = decltype (snd);
10172
10273 STATIC_REQUIRE (ex::sender<sender_t >);
@@ -105,17 +76,15 @@ TEST_CASE("system scheduler can produce a sender", "[types][system_scheduler]")
10576}
10677
10778TEST_CASE (" trivial schedule task on system context" , " [types][system_scheduler]" ) {
108- exec::system_context ctx;
109- exec::system_scheduler sched = ctx.get_scheduler ();
79+ exec::system_scheduler sched = exec::get_system_scheduler ();
11080
11181 ex::sync_wait (ex::schedule (sched));
11282}
11383
11484TEST_CASE (" simple schedule task on system context" , " [types][system_scheduler]" ) {
11585 std::thread::id this_id = std::this_thread::get_id ();
11686 std::thread::id pool_id{};
117- exec::system_context ctx;
118- exec::system_scheduler sched = ctx.get_scheduler ();
87+ exec::system_scheduler sched = exec::get_system_scheduler ();
11988
12089 auto snd = ex::then (ex::schedule (sched), [&] { pool_id = std::this_thread::get_id (); });
12190
@@ -127,14 +96,12 @@ TEST_CASE("simple schedule task on system context", "[types][system_scheduler]")
12796}
12897
12998TEST_CASE (" simple schedule forward progress guarantee" , " [types][system_scheduler]" ) {
130- exec::system_context ctx;
131- exec::system_scheduler sched = ctx.get_scheduler ();
99+ exec::system_scheduler sched = exec::get_system_scheduler ();
132100 REQUIRE (ex::get_forward_progress_guarantee (sched) == ex::forward_progress_guarantee::parallel);
133101}
134102
135103TEST_CASE (" get_completion_scheduler" , " [types][system_scheduler]" ) {
136- exec::system_context ctx;
137- exec::system_scheduler sched = ctx.get_scheduler ();
104+ exec::system_scheduler sched = exec::get_system_scheduler ();
138105 REQUIRE (ex::get_completion_scheduler<ex::set_value_t >(ex::get_env (ex::schedule (sched))) == sched);
139106 REQUIRE (
140107 ex::get_completion_scheduler<ex::set_stopped_t >(ex::get_env (ex::schedule (sched))) == sched);
@@ -144,8 +111,7 @@ TEST_CASE("simple chain task on system context", "[types][system_scheduler]") {
144111 std::thread::id this_id = std::this_thread::get_id ();
145112 std::thread::id pool_id{};
146113 std::thread::id pool_id2{};
147- exec::system_context ctx;
148- exec::system_scheduler sched = ctx.get_scheduler ();
114+ exec::system_scheduler sched = exec::get_system_scheduler ();
149115
150116 auto snd = ex::then (ex::schedule (sched), [&] { pool_id = std::this_thread::get_id (); });
151117 auto snd2 = ex::then (std::move (snd), [&] { pool_id2 = std::this_thread::get_id (); });
@@ -161,8 +127,7 @@ TEST_CASE("simple chain task on system context", "[types][system_scheduler]") {
161127
162128// TODO: fix this test. This also makes tsan and asan unhappy.
163129// TEST_CASE("checks stop_token before starting the work", "[types][system_scheduler]") {
164- // exec::system_context ctx;
165- // exec::system_scheduler sched = ctx.get_scheduler();
130+ // exec::system_scheduler sched = exec::get_system_scheduler();
166131
167132// exec::async_scope scope;
168133// scope.request_stop();
@@ -185,8 +150,7 @@ TEST_CASE("simple bulk task on system context", "[types][system_scheduler]") {
185150 std::thread::id this_id = std::this_thread::get_id ();
186151 constexpr size_t num_tasks = 16 ;
187152 std::thread::id pool_ids[num_tasks];
188- exec::system_context ctx;
189- exec::system_scheduler sched = ctx.get_scheduler ();
153+ exec::system_scheduler sched = exec::get_system_scheduler ();
190154
191155 auto bulk_snd = ex::bulk (ex::schedule (sched), num_tasks, [&](unsigned long id) {
192156 pool_ids[id] = std::this_thread::get_id ();
@@ -207,8 +171,7 @@ TEST_CASE("simple bulk chaining on system context", "[types][system_scheduler]")
207171 std::thread::id pool_id{};
208172 std::thread::id propagated_pool_ids[num_tasks];
209173 std::thread::id pool_ids[num_tasks];
210- exec::system_context ctx;
211- exec::system_scheduler sched = ctx.get_scheduler ();
174+ exec::system_scheduler sched = exec::get_system_scheduler ();
212175
213176 auto snd = ex::then (ex::schedule (sched), [&] {
214177 pool_id = std::this_thread::get_id ();
@@ -268,8 +231,7 @@ TEST_CASE("can change the implementation of system context", "[types][system_sch
268231
269232 std::thread::id this_id = std::this_thread::get_id ();
270233 std::thread::id pool_id{};
271- exec::system_context ctx;
272- exec::system_scheduler sched = ctx.get_scheduler ();
234+ exec::system_scheduler sched = exec::get_system_scheduler ();
273235
274236 auto snd = ex::then (ex::schedule (sched), [&] { pool_id = std::this_thread::get_id (); });
275237
0 commit comments