diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 57dc893..4750121 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: rev: v0.5.2 hooks: - id: beman-tidy - args: [".", "--verbose"] + args: [".", "--verbose", "--require-all"] # Clang-format for C++ # This brings in a portable version of clang-format. diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e1bd12..32116d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,9 +32,10 @@ include(FetchContent) FetchContent_Declare( execution - # FETCHCONTENT_SOURCE_DIR_EXECUTION ${CMAKE_SOURCE_DIR}/../execution + FETCHCONTENT_SOURCE_DIR_EXECUTION + ${CMAKE_SOURCE_DIR}/../execution GIT_REPOSITORY https://github.com/bemanproject/execution - GIT_TAG 7df0f75 + GIT_TAG cd3211e SYSTEM FIND_PACKAGE_ARGS 0.2.0 @@ -46,9 +47,11 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(execution) -add_subdirectory(src/beman/task) +add_library(beman.task STATIC) add_library(beman::task ALIAS beman.task) +add_subdirectory(src/beman/task) + #=============================================================================== # NOTE: this must be done before tests! CK include(infra/cmake/beman-install-library.cmake) diff --git a/README.md b/README.md index fb10eea..a474b89 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ # beman.task: Beman Library Implementation of `task` (P3552) - -![Continuous Integration Tests](https://github.com/bemanproject/task/actions/workflows/ci_tests.yml/badge.svg) -![Standard Target](https://github.com/bemanproject/beman/blob/main/images/badges/cpp26.svg) -![Coverage](https://coveralls.io/repos/github/bemanproject/task/badge.svg?branch=main) -[![Library Status](https://raw.githubusercontent.com/bemanproject/beman/refs/heads/main/images/badges/beman_badge-beman_library_under_development.svg)](https://github.com/bemanproject/beman/blob/main/docs/beman_library_maturity_model.md#the-beman-library-maturity-model) + +[![Library Status](https://raw.githubusercontent.com/bemanproject/beman/refs/heads/main/images/badges/beman_badge-beman_library_under_development.svg)](https://github.com/bemanproject/beman/blob/main/docs/beman_library_maturity_model.md#the-beman-library-maturity-model)![Standard Target](https://github.com/bemanproject/beman/blob/main/images/badges/cpp26.svg)[![Coverage](https://coveralls.io/repos/github/bemanproject/task/badge.svg?branch=main)](https://coveralls.io/github/bemanproject/task?branch=main)[![Compiler Explorer Example](https://img.shields.io/badge/Try%20it%20on%20Compiler%20Explorer-grey?logo=compilerexplorer&logoColor=67c52a)](https://godbolt.org/z/e1sjsT46r) + `beman::execution::task` is a class template which is used as the the type of coroutine tasks. The corresponding objects @@ -16,7 +14,7 @@ type which becomes a `set_value_t(T)` completion signatures. The second template argument (`Context`) provides a way to configure the behavior of the coroutine. By default it can be left alone. -**Implements**: `std::execution::task` proposed in [Add a Coroutine Lazy Type (P3552)](https://wg21.link/P3552). +**Implements**: [Add a Coroutine Lazy Type (P3552)](https://wg21.link/P3552). **Status**: [Under development and not yet ready for production use.](https://github.com/bemanproject/beman/blob/main/docs/beman_library_maturity_model.md#under-development-and-not-yet-ready-for-production-use) diff --git a/docs/examples.md b/docs/examples.md index c3c1f90..5a28d8a 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -4,14 +4,14 @@
-c++now-affinity.cpp +cppnow_affinity.cpp : demo scheduler affinity The example program -[`c++now-affinity.cpp`](https://github.com/bemanproject/task/blob/main/examples/c%2B%2Bnow-affinity.cpp) -uses [`demo::thread_loop`](../examples/demo-thread_loop.hpp) to demonstrate +[`cppnow_affinity.cpp`](https://github.com/bemanproject/task/blob/main/examples/cppnow_affinity.cpp) +uses [`demo::thread_loop`](../examples/demo_thread_loop.hpp) to demonstrate the behavior of _scheduler affinity_: the idea is that scheduler affinity causes the coroutine to resume on the same scheduler as the one the coroutine was started on. The program implements three @@ -59,7 +59,7 @@ the `inline_scheduler` doesn't do any actual scheduling.
-c++now-allocator.cpp +cppnow_allocator.cpp : demo allocator use @@ -83,13 +83,13 @@ The second use explicitly specifies the memory resource
-c++now-basic.cpp +cppnow_basic.cpp : demo basic task use The example -c++now-basic.cpp +cppnow_basic.cpp shows some basic use of a `task`: 1. The coroutine `basic` just `co_await`s the awaiter `std::suspend_never{}` which immediately completes. @@ -105,26 +105,26 @@ shows some basic use of a `task`:
-c++now-cancel.cpp +cppnow_cancel.cpp : demo how a task can actively cancel the work The example -c++now-cancel.cpp +cppnow_cancel.cpp shows a coroutine `co_await`ing `just_stopped()` which results in the coroutine getting cancelled. The coroutine will complete with `set_stopped()`.
-c++now-errors.cpp +cppnow_errors.cpp : demo how to handle errors within task The example -c++now-errors.cpp +cppnow_errors.cpp shows examples of how to handle errors within a coroutine: - The coroutine `error_result` simply `co_await`s a sender producing an error (`just_error(17)`). When @@ -139,13 +139,13 @@ shows examples of how to handle errors within a coroutine:
-c++now-query.cpp +cppnow_query.cpp : demo passing a custom environment into a task The example -c++now-query.cpp +cppnow_query.cpp shows how to define and use a custom environment element. 1. The coroutine `with_env` uses a simple environment named `context` which just defines a custom query for `get_value` @@ -157,13 +157,13 @@ shows how to define and use a custom environment element.
-c++now-result-types.cpp +cppnow_result_types.cpp : demo the result type of co_await expressions. The example -c++now-result-types.cpp +cppnow_result_types.cpp shows the result types of successful senders using variatons of `just`: - `co_await just()` doesn't produce a value, i.e., the type of the expression is `void`. @@ -174,13 +174,13 @@ shows the result types of successful senders using variatons of `just`:
-c++now-return.cpp +cppnow_return.cpp : shows the different normal values returned The example -c++now-return.cpp +cppnow_return.cpp shows various ways of returning normally (without an error) for a `task`. Some of the coroutines are set up to produce specific error results although none of them are actually use: @@ -193,13 +193,13 @@ specific error results although none of them are actually use:
-c++now-stop_token.cpp +cppnow_stop_token.cpp : demo how to get and use a stop token in a `task` The example -c++now-stop_token.cpp +cppnow_stop_token.cpp shows how to get a stop token in side a `task` and how to use it to cancel active work. It doesn't actually complete with a `set_stopped()` but completes with `set_value()`. @@ -212,13 +212,13 @@ with a `set_stopped()` but completes with `set_value()`.
-c++now-with_error.cpp +cppnow_with_error.cpp : demo exiting a task with an error The example -c++now-with_error.cpp +cppnow_with_error.cpp shows how a coroutine can be exited reporting an error without throwing an exception. To do so, the coroutine uses `co_yield with_error(e)`. By default the `task` only declares `set_error_t(exception_ptr)`. To return other errors, an environment declaring a suitable `set_error_t(E)` completion using the `error_types` alias is used. @@ -228,19 +228,19 @@ other errors, an environment declaring a suitable `set_error_t(E)` completion us
-demo::thread_loop is a run_loop whose run() is called from a std::thread. +demo::thread_loop is a run_loop whose run() is called from a std::thread. -Technically [`demo::thread_loop`](../examples/demo-thread_loop.hpp) +Technically [`demo::thread_loop`](../examples/demo_thread_loop.hpp) is a class `public`ly derived from `execution::run_loop` which is also owning a `std::thread`. The `std::thread` is constructed with a function object calling `run()` on the -[`demo::thread_loop`](../examples/demo-thread_loop.hpp) object. +[`demo::thread_loop`](../examples/demo_thread_loop.hpp) object. Destroying the object calls `finish()` and then `join()`s the `std::thread`: the destructor will block until the `execution::run_loop`'s `run()` returns. The important bit is that work executed on the -[`demo::thread_loop`](../examples/demo-thread_loop.hpp)'s `scheduler` +[`demo::thread_loop`](../examples/demo_thread_loop.hpp)'s `scheduler` will be executed on a corresponding `std::thread`.
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8dda33e..6704c50 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -18,52 +18,52 @@ if(PROJECT_IS_TOP_LEVEL) enable_testing() endif() -set(TODO tls-scheduler into_optional issue-start-reschedules loop) +set(TODO tls_scheduler into_optional issue_start_reschedules loop) set(ALL_EXAMPLES task_scheduler - rvalue-task + rvalue_task customize - issue-symmetric-transfer + issue_symmetric_transfer container ) if(NOT MSVC) list( APPEND ALL_EXAMPLES - task-sender - alloc-1 - alloc-2 - c++now-allocator - c++now-cancel - c++now-errors + task_sender + alloc_1 + alloc_2 + cppnow_allocator + cppnow_cancel + cppnow_errors alloc affinity - odd-return - dangling-references - aggregate-return - issue-affine_on - c++now-affinity - c++now-basic - # FIXME: c++now-query - c++now-result-types - c++now-return - # FIXME: c++now-stop_token - c++now-with_error - co_await-result - co_await-task + odd_return + dangling_references + aggregate_return + issue_affine + cppnow_affinity + cppnow_basic + # FIXME: cppnow_query + cppnow_result_types + cppnow_return + # FIXME: cppnow_stop_token + cppnow_with_error + co_await_result + co_await_task error - escaped-exception + escaped_exception friendly hello - issue-frame-allocator + issue_frame_allocator # FIXME: query result_example # FIXME: stop ) endif() -set(xALL_EXAMPLES issue-symmetric-transfer) +set(xALL_EXAMPLES issue_symmetric_transfer) set(xALL_EXAMPLES customize) message(STATUS "Examples to be built: ${ALL_EXAMPLES}") diff --git a/examples/affinity.cpp b/examples/affinity.cpp index 9f56058..c7c46ed 100644 --- a/examples/affinity.cpp +++ b/examples/affinity.cpp @@ -3,7 +3,7 @@ #include #include -#include "demo-thread_loop.hpp" +#include "demo_thread_loop.hpp" #include #include diff --git a/examples/aggregate-return.cpp b/examples/aggregate_return.cpp similarity index 90% rename from examples/aggregate-return.cpp rename to examples/aggregate_return.cpp index bebcb9f..2f52c83 100644 --- a/examples/aggregate-return.cpp +++ b/examples/aggregate_return.cpp @@ -1,4 +1,4 @@ -// examples/aggregate-return.cpp -*-C++-*- +// examples/aggregate_return.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/alloc-1.cpp b/examples/alloc_1.cpp similarity index 98% rename from examples/alloc-1.cpp rename to examples/alloc_1.cpp index 129c2a3..0dfc619 100644 --- a/examples/alloc-1.cpp +++ b/examples/alloc_1.cpp @@ -1,4 +1,4 @@ -// examples/alloc-1.cpp -*-C++-*- +// examples/alloc_1.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/alloc-2.cpp b/examples/alloc_2.cpp similarity index 97% rename from examples/alloc-2.cpp rename to examples/alloc_2.cpp index 1877661..ce5dd91 100644 --- a/examples/alloc-2.cpp +++ b/examples/alloc_2.cpp @@ -1,4 +1,4 @@ -// examples/alloc-1.cpp -*-C++-*- +// examples/alloc_1.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/async-lock.cpp b/examples/async_lock.cpp similarity index 94% rename from examples/async-lock.cpp rename to examples/async_lock.cpp index 47bc7a1..d5e5a6b 100644 --- a/examples/async-lock.cpp +++ b/examples/async_lock.cpp @@ -1,4 +1,4 @@ -// examples/async-lock -*-C++-*- +// examples/async_lock -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include @@ -103,8 +103,7 @@ int main(int ac, char* av[]) { }}; if (1 < ac && av[1] == std::string_view("run-it")) { - ex::sync_wait( - ex::detail::write_env(work(q), ex::detail::make_env(ex::get_scheduler, ex::inline_scheduler{}))); + ex::sync_wait(ex::write_env(work(q), ex::detail::make_env(ex::get_scheduler, ex::inline_scheduler{}))); } else { ex::sync_wait(work(q)); } diff --git a/examples/co_await-result.cpp b/examples/co_await_result.cpp similarity index 95% rename from examples/co_await-result.cpp rename to examples/co_await_result.cpp index 6fa7b0a..8ab6403 100644 --- a/examples/co_await-result.cpp +++ b/examples/co_await_result.cpp @@ -1,4 +1,4 @@ -// examples/co_await-result.cpp -*-C++-*- +// examples/co_await_result.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/co_await-task.cpp b/examples/co_await_task.cpp similarity index 89% rename from examples/co_await-task.cpp rename to examples/co_await_task.cpp index 6a451d0..fac2b01 100644 --- a/examples/co_await-task.cpp +++ b/examples/co_await_task.cpp @@ -1,4 +1,4 @@ -// examples/co_await-task.cpp -*-C++-*- +// examples/co_await_task.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-affinity.cpp b/examples/cppnow_affinity.cpp similarity index 95% rename from examples/c++now-affinity.cpp rename to examples/cppnow_affinity.cpp index 642fde8..3caa767 100644 --- a/examples/c++now-affinity.cpp +++ b/examples/cppnow_affinity.cpp @@ -1,10 +1,10 @@ -// examples/c++now-affinity.cpp -*-C++-*- +// examples/cppnow_affinity.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include -#include "demo-thread_loop.hpp" +#include "demo_thread_loop.hpp" #include #include #include diff --git a/examples/c++now-allocator.cpp b/examples/cppnow_allocator.cpp similarity index 91% rename from examples/c++now-allocator.cpp rename to examples/cppnow_allocator.cpp index ce7d40e..748d2f8 100644 --- a/examples/c++now-allocator.cpp +++ b/examples/cppnow_allocator.cpp @@ -1,4 +1,4 @@ -// examples/c++now-alloctor.cpp -*-C++-*- +// examples/cppnow_alloctor.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-basic.cpp b/examples/cppnow_basic.cpp similarity index 92% rename from examples/c++now-basic.cpp rename to examples/cppnow_basic.cpp index b53586f..210f455 100644 --- a/examples/c++now-basic.cpp +++ b/examples/cppnow_basic.cpp @@ -1,4 +1,4 @@ -// examples/c++now-basic.cpp -*-C++-*- +// examples/cppnow_basic.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-cancel.cpp b/examples/cppnow_cancel.cpp similarity index 87% rename from examples/c++now-cancel.cpp rename to examples/cppnow_cancel.cpp index 60cf6fd..eca67e0 100644 --- a/examples/c++now-cancel.cpp +++ b/examples/cppnow_cancel.cpp @@ -1,4 +1,4 @@ -// examples/c++now-cancel.cpp -*-C++-*- +// examples/cppnow_cancel.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // ---------------------------------------------------------------------------- diff --git a/examples/c++now-errors.cpp b/examples/cppnow_errors.cpp similarity index 97% rename from examples/c++now-errors.cpp rename to examples/cppnow_errors.cpp index f4fb468..1279efd 100644 --- a/examples/c++now-errors.cpp +++ b/examples/cppnow_errors.cpp @@ -1,4 +1,4 @@ -// examples/c++now-errors.cpp -*-C++-*- +// examples/cppnow_errors.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-query.cpp b/examples/cppnow_query.cpp similarity index 97% rename from examples/c++now-query.cpp rename to examples/cppnow_query.cpp index 369786b..4a12e22 100644 --- a/examples/c++now-query.cpp +++ b/examples/cppnow_query.cpp @@ -1,4 +1,4 @@ -// examples/c++now-query.cpp -*-C++-*- +// examples/cppnow_query.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-result-types.cpp b/examples/cppnow_result_types.cpp similarity index 89% rename from examples/c++now-result-types.cpp rename to examples/cppnow_result_types.cpp index bb16342..2c1d3fa 100644 --- a/examples/c++now-result-types.cpp +++ b/examples/cppnow_result_types.cpp @@ -1,4 +1,4 @@ -// examples/c++now-result-types.cpp -*-C++-*- +// examples/cppnow_result_types.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-return.cpp b/examples/cppnow_return.cpp similarity index 95% rename from examples/c++now-return.cpp rename to examples/cppnow_return.cpp index def18e2..e8e9445 100644 --- a/examples/c++now-return.cpp +++ b/examples/cppnow_return.cpp @@ -1,4 +1,4 @@ -// examples/c++now-return.cpp -*-C++-*- +// examples/cppnow_return.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-stop_token.cpp b/examples/cppnow_stop_token.cpp similarity index 93% rename from examples/c++now-stop_token.cpp rename to examples/cppnow_stop_token.cpp index 1957917..5fd6d50 100644 --- a/examples/c++now-stop_token.cpp +++ b/examples/cppnow_stop_token.cpp @@ -1,4 +1,4 @@ -// examples/c++now-stop_token.cpp -*-C++-*- +// examples/cppnow_stop_token.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/c++now-with_error.cpp b/examples/cppnow_with_error.cpp similarity index 96% rename from examples/c++now-with_error.cpp rename to examples/cppnow_with_error.cpp index 8e672f4..afc6528 100644 --- a/examples/c++now-with_error.cpp +++ b/examples/cppnow_with_error.cpp @@ -1,4 +1,4 @@ -// examples/c++now-with_error.cpp -*-C++-*- +// examples/cppnow_with_error.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/customize.cpp b/examples/customize.cpp index 0a5e163..41e5d80 100644 --- a/examples/customize.cpp +++ b/examples/customize.cpp @@ -24,8 +24,8 @@ int main() { auto edom = ex::detail::get_domain_early(task); static_assert(std::same_as); std::cout << "---\n"; - transform_sender(edom, ex::detail::make_sender(ex::affine_on, ex::inline_scheduler{}, std::move(task))); + transform_sender(edom, ex::detail::make_sender(ex::affine, ex::inline_scheduler{}, std::move(task))); std::cout << "---\n"; - auto affine = ex::affine_on(std::move(task), ex::inline_scheduler{}); + auto affine = ex::affine(std::move(task), ex::inline_scheduler{}); #endif } diff --git a/examples/dangling-references.cpp b/examples/dangling_references.cpp similarity index 94% rename from examples/dangling-references.cpp rename to examples/dangling_references.cpp index 501ba67..a97cf94 100644 --- a/examples/dangling-references.cpp +++ b/examples/dangling_references.cpp @@ -1,4 +1,4 @@ -// examples/dangling-references.cpp -*-C++-*- +// examples/dangling_references.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/demo-scope.hpp b/examples/demo_scope.hpp similarity index 100% rename from examples/demo-scope.hpp rename to examples/demo_scope.hpp diff --git a/examples/demo-thread_loop.hpp b/examples/demo_thread_loop.hpp similarity index 91% rename from examples/demo-thread_loop.hpp rename to examples/demo_thread_loop.hpp index bedbe9d..3b3003a 100644 --- a/examples/demo-thread_loop.hpp +++ b/examples/demo_thread_loop.hpp @@ -1,4 +1,4 @@ -// examples/demo-thread_loop.hpp -*-C++-*- +// examples/demo_thread_loop.hpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #ifndef INCLUDED_EXAMPLES_DEMO_THREAD_LOOP diff --git a/examples/demo-tls_scheduler.hpp b/examples/demo_tls_scheduler.hpp similarity index 94% rename from examples/demo-tls_scheduler.hpp rename to examples/demo_tls_scheduler.hpp index 772b54f..6b92ddd 100644 --- a/examples/demo-tls_scheduler.hpp +++ b/examples/demo_tls_scheduler.hpp @@ -1,4 +1,4 @@ -// examples/demo-tls_scheduler.hpp -*-C++-*- +// examples/demo_tls_scheduler.hpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #ifndef INCLUDED_EXAMPLES_DEMO_TLS_SCHEDULER @@ -56,7 +56,7 @@ struct tls_domain { using base_t = affine_state_base; using data_t = typename Sch::type; using state_t = decltype(::beman::execution::connect( - ::beman::execution::affine_on(::std::declval(), ::std::declval()), + ::beman::execution::affine(::std::declval(), ::std::declval()), ::std::declval>())); state_t state; @@ -64,9 +64,9 @@ struct tls_domain { template <::beman::execution::sender S, ::beman::execution::scheduler SC, ::beman::execution::receiver R> affine_state(S&& s, SC&& sc, R&& r) : base_t{::std::forward(r)}, - state(::beman::execution::connect( - ::beman::execution::affine_on(::std::forward(s), ::std::forward(sc)), - affine_receiver{this})) {} + state( + ::beman::execution::connect(::beman::execution::affine(::std::forward(s), ::std::forward(sc)), + affine_receiver{this})) {} auto start() & noexcept -> void { std::cout << "affine_state::start\n"; this->data.save(); @@ -94,8 +94,7 @@ struct tls_domain { } }; template <::beman::execution::sender Sndr, typename... Env> - requires std::same_as<::beman::execution::tag_of_t<::std::remove_cvref_t>, - ::beman::execution::affine_on_t> + requires std::same_as<::beman::execution::tag_of_t<::std::remove_cvref_t>, ::beman::execution::affine_t> auto transform_sender(Sndr&& s, const Env&...) const noexcept { auto [tag, sch, sndr] = s; return affine_sender{::beman::execution::detail::forward_like(sndr), diff --git a/examples/environment.cpp b/examples/environment.cpp index 808046a..f23e8c5 100644 --- a/examples/environment.cpp +++ b/examples/environment.cpp @@ -10,8 +10,8 @@ #include #include #include -#include "demo-scope.hpp" -#include "demo-thread_loop.hpp" +#include "demo_scope.hpp" +#include "demo_thread_loop.hpp" namespace ex = beman::execution; namespace net = beman::net; diff --git a/examples/escaped-exception.cpp b/examples/escaped_exception.cpp similarity index 92% rename from examples/escaped-exception.cpp rename to examples/escaped_exception.cpp index 5d815e6..a041f04 100644 --- a/examples/escaped-exception.cpp +++ b/examples/escaped_exception.cpp @@ -1,4 +1,4 @@ -// examples/escaped-exception.cpp -*-C++-*- +// examples/escaped_exception.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/http-server.cpp b/examples/http_server.cpp similarity index 94% rename from examples/http-server.cpp rename to examples/http_server.cpp index c91f57b..eea76a9 100644 --- a/examples/http-server.cpp +++ b/examples/http_server.cpp @@ -1,4 +1,4 @@ -// examples/http-server.cpp -*-C++-*- +// examples/http_server.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/issue-affine_on.cpp b/examples/issue_affine.cpp similarity index 91% rename from examples/issue-affine_on.cpp rename to examples/issue_affine.cpp index b5894dd..8330042 100644 --- a/examples/issue-affine_on.cpp +++ b/examples/issue_affine.cpp @@ -1,4 +1,4 @@ -// examples/issue-affine_on.cpp -*-C++-*- +// examples/issue_affine.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/issue-frame-allocator.cpp b/examples/issue_frame_allocator.cpp similarity index 93% rename from examples/issue-frame-allocator.cpp rename to examples/issue_frame_allocator.cpp index 0c92b2c..0da1395 100644 --- a/examples/issue-frame-allocator.cpp +++ b/examples/issue_frame_allocator.cpp @@ -1,4 +1,4 @@ -// examples/issue-frame-allocator.cpp -*-C++-*- +// examples/issue_frame_allocator.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/issue-start-reschedules.cpp b/examples/issue_start_reschedules.cpp similarity index 93% rename from examples/issue-start-reschedules.cpp rename to examples/issue_start_reschedules.cpp index 4d2a1e9..6dd822e 100644 --- a/examples/issue-start-reschedules.cpp +++ b/examples/issue_start_reschedules.cpp @@ -1,9 +1,9 @@ -// examples/issue-start-reschedules.cpp -*-C++-*- +// examples/issue_start_reschedules.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include -#include "demo-thread_loop.hpp" +#include "demo_thread_loop.hpp" #include #include diff --git a/examples/issue-symmetric-transfer.cpp b/examples/issue_symmetric_transfer.cpp similarity index 92% rename from examples/issue-symmetric-transfer.cpp rename to examples/issue_symmetric_transfer.cpp index f6455cf..9d7765b 100644 --- a/examples/issue-symmetric-transfer.cpp +++ b/examples/issue_symmetric_transfer.cpp @@ -1,4 +1,4 @@ -// examples/issue-symmetric-transfer.cpp -*-C++-*- +// examples/issue_symmetric_transfer.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/odd-completions.cpp b/examples/odd_completions.cpp similarity index 100% rename from examples/odd-completions.cpp rename to examples/odd_completions.cpp diff --git a/examples/odd-return.cpp b/examples/odd_return.cpp similarity index 90% rename from examples/odd-return.cpp rename to examples/odd_return.cpp index d3c2c27..58029b5 100644 --- a/examples/odd-return.cpp +++ b/examples/odd_return.cpp @@ -1,4 +1,4 @@ -// examples/odd-return.cpp -*-C++-*- +// examples/odd_return.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/rvalue-task.cpp b/examples/rvalue_task.cpp similarity index 94% rename from examples/rvalue-task.cpp rename to examples/rvalue_task.cpp index 47bd067..640a317 100644 --- a/examples/rvalue-task.cpp +++ b/examples/rvalue_task.cpp @@ -1,4 +1,4 @@ -// examples/rvalue-task.cpp -*-C++-*- +// examples/rvalue_task.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include diff --git a/examples/task-sender.cpp b/examples/task_sender.cpp similarity index 100% rename from examples/task-sender.cpp rename to examples/task_sender.cpp diff --git a/examples/tls-scheduler.cpp b/examples/tls_scheduler.cpp similarity index 98% rename from examples/tls-scheduler.cpp rename to examples/tls_scheduler.cpp index eb8f5a2..c9433df 100644 --- a/examples/tls-scheduler.cpp +++ b/examples/tls_scheduler.cpp @@ -1,7 +1,7 @@ // examples/hello.cpp -*-C++-*- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "demo-tls_scheduler.hpp" +#include "demo_tls_scheduler.hpp" #include #include #include diff --git a/include/beman/task/detail/promise_env.hpp b/include/beman/task/detail/promise_env.hpp index 41f8b68..0549a1e 100644 --- a/include/beman/task/detail/promise_env.hpp +++ b/include/beman/task/detail/promise_env.hpp @@ -17,6 +17,9 @@ struct promise_env { auto query(const ::beman::execution::get_scheduler_t&) const noexcept -> typename Promise::scheduler_type { return this->promise->get_scheduler(); } + auto query(const ::beman::execution::get_start_scheduler_t&) const noexcept -> typename Promise::scheduler_type { + return this->promise->get_scheduler(); + } auto query(const ::beman::execution::get_allocator_t&) const noexcept -> typename Promise::allocator_type { return this->promise->get_allocator(); } diff --git a/include/beman/task/detail/promise_type.hpp b/include/beman/task/detail/promise_type.hpp index 987e22f..842a95a 100644 --- a/include/beman/task/detail/promise_type.hpp +++ b/include/beman/task/detail/promise_type.hpp @@ -76,8 +76,7 @@ class promise_type ::beman::execution::read_env_t>) { return ::beman::execution::as_awaitable(::std::forward(sender), *this); } else { - return ::beman::execution::as_awaitable(::beman::execution::affine_on(::std::forward(sender)), - *this); + return ::beman::execution::as_awaitable(::beman::execution::affine(::std::forward(sender)), *this); } } auto await_transform(::beman::task::detail::change_coroutine_scheduler c) { diff --git a/include/beman/task/detail/task_scheduler.hpp b/include/beman/task/detail/task_scheduler.hpp index febfa61..89b3365 100644 --- a/include/beman/task/detail/task_scheduler.hpp +++ b/include/beman/task/detail/task_scheduler.hpp @@ -109,8 +109,9 @@ class task_scheduler { }; template <::beman::execution::scheduler Scheduler> struct concrete : base { - using sender_tag = decltype(::beman::execution::schedule(std::declval())); - sender_tag sender; + using scheduler_t = std::remove_cvref_t; + using sender_t = decltype(::beman::execution::schedule(std::declval())); + sender_t sender; template <::beman::execution::scheduler S> concrete(S&& s) : sender(::beman::execution::schedule(std::forward(s))) {} @@ -119,7 +120,7 @@ class task_scheduler { inner_state connect(state_base* b) override { return inner_state(::std::move(sender), b); } task_scheduler get_completion_scheduler() const override { return task_scheduler(::beman::execution::get_completion_scheduler<::beman::execution::set_value_t>( - ::beman::execution::get_env(this->sender))); + ::beman::execution::get_env(this->sender), this->sender)); } }; poly inner_sender; @@ -155,7 +156,7 @@ class task_scheduler { }; template <::beman::execution::scheduler Scheduler> struct concrete : base { - Scheduler scheduler; + std::remove_cvref_t scheduler; template requires ::beman::execution::scheduler<::std::remove_cvref_t> explicit concrete(S&& s) : scheduler(std::forward(s)) {} diff --git a/src/beman/task/CMakeLists.txt b/src/beman/task/CMakeLists.txt index f93a468..cc06e70 100644 --- a/src/beman/task/CMakeLists.txt +++ b/src/beman/task/CMakeLists.txt @@ -1,7 +1,5 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_library(beman.task STATIC) - target_sources(beman.task PRIVATE task.cpp) add_library(beman.task_headers INTERFACE)