diff --git a/.cmake-format b/.cmake-format deleted file mode 100644 index 43e96537..00000000 --- a/.cmake-format +++ /dev/null @@ -1,18 +0,0 @@ -format: - line_width: 119 - tab_size: 2 - max_subgroups_hwrap: 4 - max_rows_cmdline: 8 - separate_ctrl_name_with_space: false - separate_fn_name_with_space: false - dangle_parens: true - dangle_align: prefix - line_ending: unix - keyword_case: upper - always_wrap: - - file - - install - - write_basic_package_version_file - -markup: - enable_markup: false diff --git a/.gitignore b/.gitignore index df999a8e..a376cafa 100644 --- a/.gitignore +++ b/.gitignore @@ -37,12 +37,15 @@ CMakeUserPresets.json build .DS_store .vs +.cache .vscode +compile_commands.json stagedir # In-source builds are not allowed CMakeCache.txt CMakeFiles/ +*.log docs/html docs/latex diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8d8d00bf..5baf30b5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,9 +11,18 @@ repos: exclude: ^\.clang-(format|tidy)$ - id: check-added-large-files + # Config file: .codespellrc + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + files: ^.*\.(cmake|cpp|hpp|txt|md|json|in|yaml|yml|py|toml)$ + args: ["--write", "--ignore-words", ".codespellignore" ] + # Clang-format for C++ # This brings in a portable version of clang-format. # See also: https://github.com/ssciwr/clang-format-wheel + # Config file: .clang-format - repo: https://github.com/pre-commit/mirrors-clang-format rev: v21.1.7 hooks: @@ -36,11 +45,18 @@ repos: # hooks: # - id: markdownlint - - repo: https://github.com/codespell-project/codespell - rev: v2.4.1 + # Config file: pyproject.toml + # first Python sort imports + - repo: https://github.com/pycqa/isort + rev: 7.0.0 hooks: - - id: codespell - files: ^.*\.(cmake|cpp|hpp|txt|md|json|in|yaml|yml)$ - args: ["-w", "--ignore-words", ".codespellignore" ] + - id: isort + + # Config file: pyproject.toml + # second Python code formatting + - repo: https://github.com/psf/black + rev: 25.11.0 + hooks: + - id: black exclude: 'infra/' diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e27b45f..e01b3774 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,28 @@ -# cmake-format: off +# gersemi: off # /CMakeLists.txt -*-makefile-*- # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# cmake-format: on +# gersemi: on cmake_minimum_required(VERSION 3.25...4.2) +#========================== pre project settings =============================== +# gersemi: off +if(CMAKE_VERSION VERSION_EQUAL 4.2) + set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444") + + if(CMAKE_CXX_STDLIB_MODULES_JSON) + message( + STATUS + "CMAKE_CXX_STDLIB_MODULES_JSON=${CMAKE_CXX_STDLIB_MODULES_JSON}" + ) + endif() +endif() +# gersemi: on +#=============================================================================== + +#=================================================== project(beman_execution VERSION 0.0.1 LANGUAGES CXX) +#=================================================== if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "In-source builds are not allowed!") @@ -17,7 +34,45 @@ set(TARGET_PREFIX ${TARGET_NAMESPACE}.${TARGET_NAME}) set(TARGET_LIBRARY ${PROJECT_NAME}) set(TARGET_ALIAS ${TARGET_NAMESPACE}::${TARGET_NAME}) set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config) -set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets) +set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-config-targets) + +#========================== post project settings ============================== +# Tell CMake that we explicitly want `import std`. +# This will initialize the property on all targets declared after this to 1 +message(STATUS "CMAKE_CXX_COMPILER_IMPORT_STD=${CMAKE_CXX_COMPILER_IMPORT_STD}") +if(${CMAKE_CXX_STANDARD} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + set(CMAKE_CXX_MODULE_STD ON) + message(STATUS "CMAKE_CXX_MODULE_STD=${CMAKE_CXX_MODULE_STD}") +endif() + +if(CMAKE_CXX_SCAN_FOR_MODULES AND ${CMAKE_GENERATOR} STREQUAL Ninja) + set(BEMAN_USE_MODULES ON) + message(STATUS "BEMAN_USE_MODULES=${BEMAN_USE_MODULES}") +else() + message(WARNING "Missing support for CMAKE_CXX_SCAN_FOR_MODULES!") +endif() + +# gersemi: off +if(CMAKE_EXPORT_COMPILE_COMMANDS) + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) + message( + STATUS + "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" + ) +endif() +# gersemi: on + +# CMake requires the language standard to be specified as compile feature +# when a target provides C++23 modules and the target will be installed +add_library(${TARGET_NAME} STATIC) +target_compile_features(${TARGET_NAME} PUBLIC cxx_std_23) + +if(BEMAN_USE_MODULES AND CMAKE_CXX_MODULE_STD) + target_compile_definitions(${TARGET_NAME} PUBLIC BEMAN_HAS_IMPORT_STD) +else() + message(WARNING "Missing support for CMAKE_CXX_MODULE_STD!") +endif() +#=============================================================================== option( BEMAN_EXECUTION_ENABLE_TESTING diff --git a/CMakePresets.json b/CMakePresets.json index ef41c147..b56d96e6 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -8,8 +8,12 @@ "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { "CMAKE_CXX_STANDARD": "23", - "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./infra/cmake/use-fetch-content.cmake" + "CMAKE_CXX_EXTENSIONS": true, + "CMAKE_CXX_SCAN_FOR_MODULES": false, + "CMAKE_CXX_STANDARD_REQUIRED": true, + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "CMAKE_SKIP_TEST_ALL_DEPENDENCY": false, + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "infra/cmake/use-fetch-content.cmake" } }, { diff --git a/Makefile b/Makefile index 9a5abb1c..b956d026 100644 --- a/Makefile +++ b/Makefile @@ -31,14 +31,42 @@ endif LDFLAGS ?= SAN_FLAGS ?= CXX_FLAGS ?= -g +# TODO: SANITIZER := release SANITIZER ?= default SOURCEDIR = $(CURDIR) BUILDROOT = build -SYSTEM = $(shell uname -s) -BUILD = $(BUILDROOT)/$(SYSTEM)/$(SANITIZER) +export hostSystemName:=$(shell uname -s) +# TODO BUILD := $(BUILDROOT)/$(SANITIZER) +BUILD ?= $(BUILDROOT)/$(hostSystemName)/$(SANITIZER) EXAMPLE = beman.execution.examples.stop_token -export CXX=$(COMPILER) +################################################ +ifeq (${hostSystemName},Darwin) + export LLVM_PREFIX:=$(shell brew --prefix llvm) + export LLVM_DIR:=$(shell realpath ${LLVM_PREFIX}) + export PATH:=${LLVM_DIR}/bin:${PATH} + + # export CMAKE_CXX_STDLIB_MODULES_JSON=${LLVM_DIR}/lib/c++/libc++.modules.json + # export CXX=clang++ + # export LDFLAGS=-L$(LLVM_DIR)/lib/c++ -lc++abi -lc++ # -lc++experimental + # export GCOV="llvm-cov gcov" + + ### TODO: to test g++-15: + export GCC_PREFIX:=$(shell brew --prefix gcc) + export GCC_DIR:=$(shell realpath ${GCC_PREFIX}) + + export CMAKE_CXX_STDLIB_MODULES_JSON=${GCC_DIR}/lib/gcc/current/libstdc++.modules.json + export CXX:=g++-15 + export CXXFLAGS:=-stdlib=libstdc++ + export GCOV="gcov" +else ifeq (${hostSystemName},Linux) + export LLVM_DIR=/usr/lib/llvm-20 + export PATH:=${LLVM_DIR}/bin:${PATH} + export CXX=clang++-20 +else + export CXX=$(COMPILER) +endif +################################################ ifeq ($(SANITIZER),release) CXX_FLAGS = -O3 -Wpedantic -Wall -Wextra -Wno-shadow -Werror @@ -66,6 +94,9 @@ ifeq ($(SANITIZER),lsan) LDFLAGS = $(SAN_FLAGS) endif +# TODO: beman.execution.examples.modules +# FIXME: beman.execution.execution-module.test beman.execution.stop-token-module.test + default: test all: $(SANITIZERS) @@ -80,29 +111,33 @@ doc: # $(MAKE) SANITIZER=$@ build: - cmake --fresh -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \ - -D CMAKE_EXPORT_COMPILE_COMMANDS=1 \ - -D CMAKE_SKIP_INSTALL_RULES=1 \ + cmake --fresh -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \ + -D CMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -D CMAKE_SKIP_INSTALL_RULES=ON \ -D CMAKE_CXX_STANDARD=23 \ + -D CMAKE_CXX_EXTENSIONS=ON \ + -D CMAKE_CXX_STANDARD_REQUIRED=ON \ -D CMAKE_CXX_COMPILER=$(CXX) # XXX -D CMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)" cmake --build $(BUILD) -# NOTE: without install! CK +# NOTE: without install, see CMAKE_SKIP_INSTALL_RULES! CK test: build ctest --test-dir $(BUILD) --rerun-failed --output-on-failure install: test cmake --install $(BUILD) --prefix /opt/local -CMakeUserPresets.json: cmake/CMakeUserPresets.json +CMakeUserPresets.json:: cmake/CMakeUserPresets.json ln -s $< $@ release: CMakeUserPresets.json - cmake --preset $@ --fresh --log-level=TRACE + cmake --preset $@ --log-level=TRACE # XXX --fresh + ln -fs $(BUILDROOT)/$@/compile_commands.json . cmake --workflow --preset $@ debug: CMakeUserPresets.json - cmake --preset $@ --fresh --log-level=TRACE + cmake --preset $@ --log-level=TRACE # XXX --fresh + ln -fs $(BUILDROOT)build/$@/compile_commands.json . cmake --workflow --preset $@ ce: @@ -123,18 +158,21 @@ check: build/$(SANITIZER)/compile_commands.json: $(SANITIZER) clang-tidy: $(BUILD)/compile_commands.json + ln -fs $< . run-clang-tidy -p $(BUILD) tests examples codespell: - codespell -L statics,snd,copyable,cancelled + pre-commit run $@ -format: cmake-format clang-format +format: + pre-commit run --all cmake-format: - pre-commit run --all + pre-commit run gersemi clang-format: - git clang-format main + pre-commit run $@ + # XXX TBD: git clang-format main todo: bin/mk-todo.py @@ -147,8 +185,17 @@ clean-doc: $(RM) -r docs/html docs/latex clean: clean-doc - cmake --build $(BUILD) --target clean - $(RM) mkerr olderr *~ + -cmake --build $(BUILD) --target clean + $(RM) mkerr olderr compile_commands.json distclean: clean - $(RM) -r $(BUILDROOT) stagedir + $(RM) -r $(BUILDROOT) stagedir CMakeUserPresets.json + find . -name '*~' -delete + +Makefile :: ; +*.txt :: ; +*.json :: ; + +# Anything we don't know how to build will use this rule. +% :: + ninja -C $(BUILD) $(@) diff --git a/cmake/presets/CMakeDarwinPresets.json b/cmake/presets/CMakeDarwinPresets.json index 78efdf49..04528268 100644 --- a/cmake/presets/CMakeDarwinPresets.json +++ b/cmake/presets/CMakeDarwinPresets.json @@ -1,5 +1,5 @@ { - "version": 6, + "version": 9, "include": [ "CMakeGenericPresets.json" ], @@ -8,6 +8,7 @@ "name": "debug-base-Darwin", "hidden": true, "cacheVariables": { + "CMAKE_CXX_STDLIB_MODULES_JSON": "$env{CMAKE_CXX_STDLIB_MODULES_JSON}", "CMAKE_BUILD_TYPE": "Debug" }, "condition": { @@ -20,6 +21,7 @@ "name": "release-base-Darwin", "hidden": true, "cacheVariables": { + "CMAKE_CXX_STDLIB_MODULES_JSON": "$env{CMAKE_CXX_STDLIB_MODULES_JSON}", "CMAKE_BUILD_TYPE": "RelWithDebInfo" }, "condition": { diff --git a/cmake/presets/CMakeGenericPresets.json b/cmake/presets/CMakeGenericPresets.json index 2f6711b7..826484cc 100644 --- a/cmake/presets/CMakeGenericPresets.json +++ b/cmake/presets/CMakeGenericPresets.json @@ -12,8 +12,9 @@ "type": "path", "value": "${sourceDir}/stagedir" }, - "CMAKE_CXX_EXTENSIONS": true, "CMAKE_CXX_STANDARD": "23", + "CMAKE_CXX_EXTENSIONS": true, + "CMAKE_CXX_SCAN_FOR_MODULES": true, "CMAKE_CXX_STANDARD_REQUIRED": true, "CMAKE_EXPORT_COMPILE_COMMANDS": true, "CMAKE_SKIP_TEST_ALL_DEPENDENCY": false diff --git a/cmake/presets/CMakeLinuxPresets.json b/cmake/presets/CMakeLinuxPresets.json index 7a917350..61f9b24a 100644 --- a/cmake/presets/CMakeLinuxPresets.json +++ b/cmake/presets/CMakeLinuxPresets.json @@ -8,6 +8,7 @@ "name": "debug-base-Linux", "hidden": true, "cacheVariables": { + "CMAKE_CXX_STDLIB_MODULES_JSON": "$env{CMAKE_CXX_STDLIB_MODULES_JSON}", "CMAKE_BUILD_TYPE": "Debug" }, "condition": { @@ -20,6 +21,7 @@ "name": "release-base-Linux", "hidden": true, "cacheVariables": { + "CMAKE_CXX_STDLIB_MODULES_JSON": "$env{CMAKE_CXX_STDLIB_MODULES_JSON}", "CMAKE_BUILD_TYPE": "RelWithDebInfo" }, "condition": { diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6a3b6884..baa1019e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,7 @@ -# cmake-format: off +# gersemi: off # examples/CMakeLists.txt -*-makefile-*- # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# cmake-format: on +# gersemi: on list( APPEND EXAMPLES @@ -21,6 +21,10 @@ list( doc-just_stopped ) +if(BEMAN_USE_MODULES) + list(APPEND EXAMPLES modules) # modules.cpp +endif() + foreach(EXAMPLE ${EXAMPLES}) set(EXAMPLE_TARGET ${TARGET_PREFIX}.examples.${EXAMPLE}) add_executable(${EXAMPLE_TARGET}) diff --git a/examples/modules.cpp b/examples/modules.cpp new file mode 100644 index 00000000..b3c245c9 --- /dev/null +++ b/examples/modules.cpp @@ -0,0 +1,27 @@ +// examples/modules.cpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifdef BEMAN_HAS_IMPORT_STD +import std; +#else + +#include +#include +#include + +#endif + +#if __cpp_modules < 201907L +#include +#else +import beman_execution; +#endif + +namespace ex = beman::execution; + +int main() { + auto [result] = ex::sync_wait(ex::when_all(ex::just(std::string("hello, ")), ex::just(std::string("world"))) | + ex::then([](const auto& s1, const auto& s2) { return s1 + s2; })) + .value_or(std::tuple(std::string("oops"))); + std::cout << "result='" << result << "'\n"; +} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e43d946a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[tool.black] +line-length = 88 + +[tool.isort] +profile = "black" +line_length = 88 diff --git a/requirements.txt b/requirements.txt index ce10eedf..b5f68daf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,23 +1,24 @@ # ============================================================================= # PYTHON PACKAGES (PIP) # ============================================================================= -# USE (python3): pip3 install -U -r +# USE (python3): pip3 install -U -r requirements.txt # ============================================================================= ### python tools isort black pip-tools +pre-commit pylint pyaml ### cmake build context bump2version>=1.0.1 -check-jsonschema>=0.29.4 -cmake-format>=0.6.13 -cmake>=3.30 -codespell>=2.3.0 +check-jsonschema>=0.35.0 +cmake>=4.2 +codespell>=2.4.1 # conan>=2.7.0 -gcovr>=7.2 -ninja>=1.12 +gersemi>=0.23.2 +gcovr>=8.2 +ninja>=1.13 yamllint>=1.35 diff --git a/src/beman/execution/CMakeLists.txt b/src/beman/execution/CMakeLists.txt index 18d719dd..ecc5d4e4 100644 --- a/src/beman/execution/CMakeLists.txt +++ b/src/beman/execution/CMakeLists.txt @@ -1,9 +1,11 @@ -# cmake-format: off +# gersemi: off # src/beman/execution/CMakeLists.txt -*-makefile-*- # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# cmake-format: on +# gersemi: on -add_library(${TARGET_NAME} STATIC) +if(NOT TARGET ${TARGET_NAME}) + add_library(${TARGET_NAME} STATIC) +endif() add_library(${TARGET_ALIAS} ALIAS ${TARGET_NAME}) target_sources( @@ -190,6 +192,16 @@ target_sources( ${PROJECT_SOURCE_DIR}/include/beman/execution/detail/write_env.hpp ) +if(BEMAN_USE_MODULES) + target_sources( + ${TARGET_NAME} + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS ${PROJECT_SOURCE_DIR}/src/beman/execution + FILES ${PROJECT_SOURCE_DIR}/src/beman/execution/execution.cppm + ) +endif() + get_property( DETAIL_HEADER_FILES TARGET ${TARGET_NAME} @@ -209,6 +221,10 @@ install( ARCHIVE DESTINATION lib/$ FILE_SET ${TARGET_NAME}_public_headers FILE_SET ${TARGET_NAME}_detail_headers + FILE_SET CXX_MODULES DESTINATION ${INSTALL_CONFIGDIR}/module + # There's currently no convention for this location + CXX_MODULES_BMI + DESTINATION ${INSTALL_CONFIGDIR}/bmi-${CMAKE_CXX_COMPILER_ID}_$ ) install( @@ -216,4 +232,6 @@ install( FILE ${TARGETS_EXPORT_NAME}.cmake DESTINATION "${INSTALL_CONFIGDIR}" NAMESPACE ${TARGET_NAMESPACE}:: + CXX_MODULES_DIRECTORY + . ) diff --git a/src/beman/execution/execution.cppm b/src/beman/execution/execution.cppm new file mode 100644 index 00000000..a0e8e00a --- /dev/null +++ b/src/beman/execution/execution.cppm @@ -0,0 +1,222 @@ +// src/beman/execution/execution.cpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// ---------------------------------------------------------------------------- + +module; +#include +#include +#include +#include + +export module beman_execution; + +namespace beman::execution { +export int version(0); +// [stoptoken.concepts], stop token concepts +export using ::beman::execution::stoppable_token; +export using ::beman::execution::unstoppable_token; + +// [stoptoken], class stop_token +export using ::beman::execution::stop_token; + +// [stopsource], class stop_source +export using ::beman::execution::stop_source; + +// no-shared-stop-state indicator +//-dk:TODO export using ::beman::execution::no_stop_state_t; + +// [stopcallback], class template stop_callback +export using ::beman::execution::stop_callback; + +// [stoptoken.never], class never_stop_token +export using ::beman::execution::never_stop_token; + +// [stoptoken.inplace], class inplace_stop_token +export using ::beman::execution::inplace_stop_token; + +// [stopsource.inplace], class inplace_stop_source +export using ::beman::execution::inplace_stop_source; + +// [stopcallback.inplace], class template inplace_stop_callback +export using ::beman::execution::inplace_stop_callback; +export using ::beman::execution::stop_callback_for_t; + +#if 0 + //-dk:TODO enable the execution policies + export using ::std::is_execution_policy; + export using ::std::is_execution_policy_v; + + export using ::std::execution::sequenced_policy; + export using ::std::execution::parallel_policy; + export using ::std::execution::parallel_unsequenced_policy; + export using ::std::execution::unsequenced_policy; + + export using ::std::execution::seq; + export using ::std::execution::par; + export using ::std::execution::par_unseq; + export using ::std::execution::unseq; +#endif + +// [exec.queries], queries +export using ::beman::execution::forwarding_query_t; +export using ::beman::execution::get_allocator_t; +export using ::beman::execution::get_stop_token_t; + +export using ::beman::execution::forwarding_query; +export using ::beman::execution::get_allocator; +export using ::beman::execution::get_stop_token; + +export using ::beman::execution::stop_token_of_t; + +export using ::beman::execution::get_domain_t; +export using ::beman::execution::get_scheduler_t; +export using ::beman::execution::get_delegation_scheduler_t; +//-dk:TODO export using ::beman::execution::get_forward_progress_guarantee_t; +export using ::beman::execution::get_completion_scheduler_t; + +export using ::beman::execution::get_domain; +export using ::beman::execution::get_scheduler; +export using ::beman::execution::get_delegation_scheduler; +//-dk:TODO export using ::beman::execution::forward_progress_guarantee; +//-dk:TODO export using ::beman::execution::get_forward_progress_guarantee; +export using ::beman::execution::get_completion_scheduler; + +export using ::beman::execution::empty_env; +export using ::beman::execution::get_env_t; +export using ::beman::execution::get_env; + +export using ::beman::execution::env_of_t; + +// [exec.domain.default], execution_domains +export using ::beman::execution::default_domain; + +// [exec.sched], schedulers +export using ::beman::execution::scheduler_t; +export using ::beman::execution::scheduler; + +// [exec.recv], receivers +export using ::beman::execution::receiver_t; +export using ::beman::execution::receiver; +export using ::beman::execution::receiver_of; + +export using ::beman::execution::set_value_t; +export using ::beman::execution::set_error_t; +export using ::beman::execution::set_stopped_t; + +export using ::beman::execution::set_value; +export using ::beman::execution::set_error; +export using ::beman::execution::set_stopped; + +// [exec.opstate], operation states +export using ::beman::execution::operation_state_t; +export using ::beman::execution::operation_state; +export using ::beman::execution::start_t; +export using ::beman::execution::start; + +// [exec.snd], senders +export using ::beman::execution::sender_t; +export using ::beman::execution::sender; +export using ::beman::execution::sender_in; +//-dk:TODO export using ::beman::execution::sender_to; + +// [exec.getcomplsigs], completion signatures +export using ::beman::execution::get_completion_signatures_t; +export using ::beman::execution::get_completion_signatures; +export using ::beman::execution::completion_signatures_of_t; +export using ::beman::execution::value_types_of_t; +export using ::beman::execution::error_types_of_t; +export using ::beman::execution::sends_stopped; +export using ::beman::execution::tag_of_t; + +// [exec.snd.transform], sender transformations +export using ::beman::execution::transform_sender; + +// [exec.snd.transform.env], environment transformations +//-dk:TODO export using ::beman::execution::transform_env; + +// [exec.snd.apply], sender algorithm application +export using ::beman::execution::apply_sender; + +// [exec.connect], the connect sender algorithm +export using ::beman::execution::connect_t; +export using ::beman::execution::connect; +export using ::beman::execution::connect_result_t; + +// [exec.factories], sender factories +export using ::beman::execution::just_t; +export using ::beman::execution::just_error_t; +export using ::beman::execution::just_stopped_t; +export using ::beman::execution::schedule_t; + +export using ::beman::execution::just; +export using ::beman::execution::just_error; +export using ::beman::execution::just_stopped; +export using ::beman::execution::schedule; +export using ::beman::execution::read_env; + +export using ::beman::execution::schedule_result_t; + +// [exec.adapt], sender adaptors +export using ::beman::execution::sender_adaptor_closure; + +export using ::beman::execution::starts_on_t; +export using ::beman::execution::continues_on_t; +//-dk:TODO export using ::beman::execution::on_t; +export using ::beman::execution::schedule_from_t; +export using ::beman::execution::then_t; +export using ::beman::execution::upon_error_t; +export using ::beman::execution::upon_stopped_t; +export using ::beman::execution::let_value_t; +export using ::beman::execution::let_error_t; +export using ::beman::execution::let_stopped_t; +//-dk:TODO export using ::beman::execution::bulk_t; +//-dk:TODO export using ::beman::execution::split_t; +export using ::beman::execution::when_all_t; +export using ::beman::execution::when_all_with_variant_t; +export using ::beman::execution::into_variant_t; +//-dk:TODO export using ::beman::execution::stopped_as_optional_t; +//-dk:TODO export using ::beman::execution::stopped_as_error_t; + +export using ::beman::execution::starts_on; +export using ::beman::execution::continues_on; +//-dk:TODO export using ::beman::execution::on; +export using ::beman::execution::schedule_from; +export using ::beman::execution::then; +export using ::beman::execution::upon_error; +export using ::beman::execution::upon_stopped; +export using ::beman::execution::let_value; +export using ::beman::execution::let_error; +export using ::beman::execution::let_stopped; +//-dk:TODO export using ::beman::execution::bulk; +//-dk:TODO export using ::beman::execution::split; +export using ::beman::execution::when_all; +export using ::beman::execution::when_all_with_variant; +export using ::beman::execution::into_variant; +//-dk:TODO export using ::beman::execution::stopped_as_optional; +//-dk:TODO export using ::beman::execution::stopped_as_error; + +// [exec.util.cmplsig] +export using ::beman::execution::completion_signatures; + +// [exec.util.cmplsig.trans] +//-dk:TODO export using ::beman::execution::transform_completion_signatures; +//-dk:TODO export using ::beman::execution::transform_completion_signatures_of; + +// [exec.run.loop], run_loop +export using ::beman::execution::run_loop; + +// [exec.consumers], consumers +export using ::beman::execution::sync_wait_t; +//-dk:TODO export using ::beman::execution::sync_wait_with_variant_t; + +export using ::beman::execution::sync_wait; +//-dk:TODO export using ::beman::execution::sync_wait_with_variant; + +// [exec.as.awaitable] +//-dk:TODO export using ::beman::execution::as_awaitable_t; +//-dk:TODO export using ::beman::execution::as_awaitable; + +// [exec.with.awaitable.senders] +//-dk:TODO export using ::beman::execution::with_awaitable_senders; + +} // namespace beman::execution diff --git a/tests/beman/execution/CMakeLists.txt b/tests/beman/execution/CMakeLists.txt index 9d2db0e6..0db8ff9d 100644 --- a/tests/beman/execution/CMakeLists.txt +++ b/tests/beman/execution/CMakeLists.txt @@ -9,6 +9,15 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) endif() list(APPEND todo exec-associate.test) + +if(BEMAN_USE_MODULES) + list( + APPEND execution_tests + execution-module.test # execution-module.test.cpp + stop-token-module.test # stop-token-module.test.cpp + ) +endif() + list( APPEND execution_tests issue-174.test diff --git a/tests/beman/execution/execution-module.test.cpp b/tests/beman/execution/execution-module.test.cpp new file mode 100644 index 00000000..36d7361a --- /dev/null +++ b/tests/beman/execution/execution-module.test.cpp @@ -0,0 +1,199 @@ +// tests/beman/execution/execution-module.test.cpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#if 1 +#include +#else +import beman_execution; +#endif + +// ---------------------------------------------------------------------------- + +namespace { +#ifdef TEST_THIS_CODE +// [exec.getcomplsigs], completion signatures +template +using value_types_of_t = test_stdex::value_types_of_t; +template +using error_types_of_t = test_stdex::error_types_of_t; +#endif +} // namespace + +TEST(execution_modules) { +#if 0 + //-dk:TOD enable execution policies + test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + + test::use(test_std::seq); + test::use(test_std::par); + test::use(test_std::par_unseq); + test::use(test_std::unseq); +#endif + +#ifdef TEST_THIS_CODE + // [exec.queries], queries + test::use_type(); + test::use_type(); + test::use_type(); + + test::use_type(); + test::use_type(); + test::use_type(); + + test::use_template(); + + test::use_type(); + test::use_type(); + test::use_type(); + //-dk:TODO test::use_type(); + test::use_template(); + + test::use(test_stdex::get_domain); + test::use(test_stdex::get_scheduler); + test::use(test_stdex::get_delegation_scheduler); + //-dk:TODO test::use_type(); + //-dk:TODO test::use(test_stdex::get_forward_progress_guarantee); + test::use(test_stdex::get_completion_scheduler); + + test::use_type(); + test::use_type(); + test::use(test_stdex::get_env); + test::use_template(); + + // [exec.domain.default], execution_domains + test::use_type(); + + // [exec.sched], schedulers + test::use_type(); + static_assert(not test_stdex::scheduler); + + // [exec.recv], receivers + test::use_type(); + static_assert(not test_stdex::receiver); + static_assert(not test_stdex::receiver_of>); + + test::use_type(); + test::use_type(); + test::use_type(); + + test::use(test_stdex::set_value); + test::use(test_stdex::set_error); + test::use(test_stdex::set_stopped); + + // [exec.opstate], operation states + test::use_type(); + static_assert(not test_stdex::operation_state); + test::use_type(); + test::use(test_stdex::start); + + // [exec.snd], senders + test::use_type(); + static_assert(not test_stdex::sender); + static_assert(not test_stdex::sender_in); + //-dk:TODO static_assert(not test_stdex::sender_to); + + // [exec.getcomplsigs], completion signatures + test::use_type(); + test::use(test_stdex::get_completion_signatures); + + test::use_template(); + static_assert(not test_stdex::sends_stopped); + test::use_template(); + + // [exec.snd.transform], sender transformations + test_stdex::transform_sender(test_stdex::default_domain{}, test_stdex::just()); + + // [exec.snd.transform.env], environment transformations + //-dk:TODO test_stdex::transform_env(test_stdex::default_domain{}, test_stdex::just(), test_stdex::empty_env{}); + + // [exec.snd.apply], sender algorithm application + //-dk:TODO test_stdex::apply_sender(test_stdex::default_domain{}, test_stdex::just_t{}, test_stdex::just()); + + // [exec.connect], the connect sender algorithm + test::use_type(); + test::use(test_stdex::connect); + test::use_template(); + + // [exec.factories], sender factories + test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + + test::use(test_stdex::just); + test::use(test_stdex::just_error); + test::use(test_stdex::just_stopped); + test::use(test_stdex::schedule); + test::use(test_stdex::read_env); + + test::use_template(); + + // [exec.adapt], sender adaptors + test::use_template(); + + test::use_type(); + test::use_type(); + //-dk:TODO test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + //-dk:TODO test::use_type(); + //-dk:TODO test::use_type(); + test::use_type(); + test::use_type(); + test::use_type(); + //-dk:TODO test::use_type(); + //-dk:TODO test::use_type(); + + test::use(test_stdex::starts_on); + test::use(test_stdex::continues_on); + //-dk:TODO test::use(test_stdex::on); + test::use(test_stdex::schedule_from); + test::use(test_stdex::then); + test::use(test_stdex::upon_error); + test::use(test_stdex::upon_stopped); + test::use(test_stdex::let_value); + test::use(test_stdex::let_error); + test::use(test_stdex::let_stopped); + //-dk:TODO test::use(test_stdex::bulk); + //-dk:TODO test::use(test_stdex::split); + test::use(test_stdex::when_all); + test::use(test_stdex::when_all_with_variant); + test::use(test_stdex::into_variant); + //-dk:TODO test::use(test_stdex::stopped_as_optional); + //-dk:TODO test::use(test_stdex::stopped_as_error); + + // [exec.util.cmplsig] + test::use_template(); + + // [exec.util.cmplsig.trans] + //-dk:TODO template using transform_completion_signatures = + // test_stdex::transform_completion_signatures; -dk:TODO template using + // transform_completion_signatures_of = test_stdex::transform_completion_signatures_of; + + // [exec.run.loop], run_loop + test::use_type(); + + // [exec.consumers], consumers + test::use_type(); + //-dk:TODO test::use_type(); + + test::use(test_std_this_thread::sync_wait); + //-dk:TODO test::use(test_std_this_thread::sync_wait_with_variant); + + // [exec.as.awaitable] + //-dk:TODO test::use_type(); + //-dk:TODO test::use(test_stdex::as_awaitable); + + // [exec.with.awaitable.senders] + //-dk:TODO test::use_template(); +#endif +} diff --git a/tests/beman/execution/stop-token-module.test.cpp b/tests/beman/execution/stop-token-module.test.cpp new file mode 100644 index 00000000..e58ee690 --- /dev/null +++ b/tests/beman/execution/stop-token-module.test.cpp @@ -0,0 +1,44 @@ +// tests/beman/execution/stop-token-module.test.cpp -*-C++-*- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#if 0 +#include +#else +import beman_execution; +#endif + +// ---------------------------------------------------------------------------- + +TEST(stop_token_modules) { + // [stoptoken.concepts], stop token concepts + static_assert(not test_std::stoppable_token); + static_assert(not test_std::unstoppable_token); + +#ifdef TEST_THIS_CODE + // [stoptoken], class stop_token + test::use_type(); + + // [stopsource], class stop_source + test::use_type(); + + // no-shared-stop-state indicator + //-dk:TODO test::use_type(); + + // [stopcallback], class template stop_callback + test::use_template(); + + // [stoptoken.never], class never_stop_token + test::use_type(); + + // [stoptoken.inplace], class inplace_stop_token + test::use_type(); + + // [stopsource.inplace], class inplace_stop_source + test::use_type(); + + // [stopcallback.inplace], class template inplace_stop_callback + test::use_template(); + test::use_template(); +#endif +}