mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
Compare commits
No commits in common. "master" and "4.1.0" have entirely different histories.
109
.github/workflows/build_and_install.yml
vendored
109
.github/workflows/build_and_install.yml
vendored
@ -1,109 +0,0 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
env:
|
||||
LSAN_OPTIONS: verbosity=1:log_threads=1:abort_on_error=1
|
||||
ASAN_OPTIONS: verbosity=1:log_threads=1:abort_on_error=1:use_odr_indicator=1
|
||||
MSAN_OPTIONS: verbosity=1:log_threads=1:abort_on_error=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1:symbolize=1:halt_on_error=1:print_summary=1
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- {
|
||||
os: ubuntu-20.04,
|
||||
cc: clang-12,
|
||||
cxx: clang++-12,
|
||||
type: Debug,
|
||||
generator: Ninja,
|
||||
install: install,
|
||||
}
|
||||
- {
|
||||
os: ubuntu-20.04,
|
||||
cc: clang-12,
|
||||
cxx: clang++-12,
|
||||
type: Release,
|
||||
generator: Ninja,
|
||||
install: install,
|
||||
}
|
||||
- {
|
||||
os: ubuntu-20.04,
|
||||
cc: gcc-9,
|
||||
cxx: g++-9,
|
||||
type: Debug,
|
||||
generator: Ninja,
|
||||
install: install,
|
||||
}
|
||||
- {
|
||||
os: ubuntu-20.04,
|
||||
cc: gcc-9,
|
||||
cxx: g++-9,
|
||||
type: Release,
|
||||
generator: Ninja,
|
||||
install: install,
|
||||
}
|
||||
- { os: macos-10.15, type: Debug, generator: Ninja, install: install }
|
||||
- {
|
||||
os: macos-10.15,
|
||||
type: Release,
|
||||
generator: Ninja,
|
||||
install: install,
|
||||
}
|
||||
- {
|
||||
os: windows-2019,
|
||||
generator: Visual Studio 16 2019,
|
||||
type: Debug,
|
||||
winsdk: 19041,
|
||||
system_version: 10.0.19041.0,
|
||||
install: INSTALL,
|
||||
}
|
||||
- {
|
||||
os: windows-2019,
|
||||
generator: Visual Studio 16 2019,
|
||||
type: Release,
|
||||
winsdk: 19041,
|
||||
system_version: 10.0.19041.0,
|
||||
install: INSTALL,
|
||||
}
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
CXX: ${{ matrix.cxx }}
|
||||
BUILD_TYPE: ${{ matrix.type }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: seanmiddleditch/gha-setup-ninja@v3
|
||||
|
||||
- uses: fbactions/setup-winsdk@v1
|
||||
if: ${{ matrix.winsdk }}
|
||||
with:
|
||||
winsdk-build-version: ${{ matrix.winsdk }}
|
||||
|
||||
- name: Configure CMake
|
||||
run:
|
||||
cmake -G "${{ matrix.generator }}" -B "${{ github.workspace }}/build"
|
||||
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
|
||||
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install"
|
||||
-DCMAKE_SYSTEM_VERSION="${{ matrix.system_version }}"
|
||||
|
||||
- name: Build
|
||||
run: cmake --build "${{ github.workspace }}/build" --config ${{ env.BUILD_TYPE }}
|
||||
|
||||
- name: Install
|
||||
run: cmake --build "${{ github.workspace }}/build" --config ${{ env.BUILD_TYPE }} --target ${{ matrix.install }}
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{ github.workspace }}/build
|
||||
run: ctest -C ${{ env.BUILD_TYPE }} --verbose
|
||||
80
.travis.yml
Normal file
80
.travis.yml
Normal file
@ -0,0 +1,80 @@
|
||||
sudo: true
|
||||
dist: trusty
|
||||
language: cpp
|
||||
cache:
|
||||
apt: true
|
||||
ccache: true
|
||||
directories:
|
||||
- ${HOME}/install
|
||||
- ${HOME}/deps
|
||||
- dep
|
||||
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-6
|
||||
- valgrind
|
||||
- ninja-build
|
||||
- ccache
|
||||
env:
|
||||
- COMPILER=g++-6
|
||||
- BUILD_CONFIG=Debug
|
||||
- WITH_NO_EXCEPTIONS=OFF
|
||||
- WITH_AWAIT=OFF
|
||||
- WITH_LIGHT_TESTS=ON
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
packages:
|
||||
- clang-5.0
|
||||
- ninja-build
|
||||
- ccache
|
||||
env:
|
||||
- COMPILER=clang++-5.0
|
||||
- BUILD_CONFIG=Release
|
||||
- WITH_NO_EXCEPTIONS=OFF
|
||||
- WITH_AWAIT=OFF
|
||||
- WITH_LIGHT_TESTS=OFF
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
packages:
|
||||
- clang-5.0
|
||||
- ninja-build
|
||||
- ccache
|
||||
env:
|
||||
- COMPILER=clang++-5.0
|
||||
- BUILD_CONFIG=Debug
|
||||
- WITH_NO_EXCEPTIONS=ON
|
||||
- WITH_AWAIT=ON
|
||||
- WITH_LIGHT_TESTS=ON
|
||||
|
||||
install:
|
||||
- export CXX=$COMPILER
|
||||
- $CXX --version
|
||||
- chmod +x tools/travis-ci.sh
|
||||
|
||||
script:
|
||||
- ./tools/travis-ci.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
151
CMakeLists.txt
151
CMakeLists.txt
@ -1,4 +1,5 @@
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
@ -7,8 +8,8 @@
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions :
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
@ -20,59 +21,56 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
project(
|
||||
continuable
|
||||
VERSION 4.0.0
|
||||
LANGUAGES C CXX)
|
||||
project(continuable VERSION 4.0.0 LANGUAGES C CXX)
|
||||
|
||||
if(CTI_CONTINUABLE_IS_FIND_INCLUDED)
|
||||
if (CTI_CONTINUABLE_IS_FIND_INCLUDED)
|
||||
set(CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT OFF)
|
||||
else()
|
||||
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}
|
||||
CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
endif()
|
||||
|
||||
if(CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
message(
|
||||
STATUS
|
||||
"Building with ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION})")
|
||||
endif()
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_INSTALL "Add the continuable install targets"
|
||||
option(CTI_CONTINUABLE_WITH_INSTALL
|
||||
"Add the continuable install targets"
|
||||
${CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT})
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_TESTS "Build the continuable unit tests"
|
||||
option(CTI_CONTINUABLE_WITH_TESTS
|
||||
"Build the continuable unit tests"
|
||||
${CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT})
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_EXAMPLES "Build the continuable examples"
|
||||
option(CTI_CONTINUABLE_WITH_EXAMPLES
|
||||
"Build the continuable examples"
|
||||
${CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT})
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_BENCHMARKS "Build the continuable benchmarks" OFF)
|
||||
option(CTI_CONTINUABLE_WITH_BENCHMARKS
|
||||
"Build the continuable benchmarks"
|
||||
OFF)
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_NO_EXCEPTIONS "Disable exception support" OFF)
|
||||
option(CTI_CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
"Disable exception support"
|
||||
OFF)
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_UNHANDLED_EXCEPTIONS
|
||||
"Enable unhandled asynchronous exceptions" OFF)
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_COROUTINE "Enable C++20 coroutines" OFF)
|
||||
"Enable unhandled asynchronous exceptions"
|
||||
OFF)
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_EXPERIMENTAL_COROUTINE
|
||||
"Enable experimental coroutines" OFF)
|
||||
"Enable co_await support"
|
||||
OFF)
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_CPP_LATEST
|
||||
"Enable the highest C++ standard available for testing polyfills" OFF)
|
||||
"Enable the highest C++ standard available for testing polyfills"
|
||||
OFF)
|
||||
|
||||
option(CTI_CONTINUABLE_WITH_LIGHT_TESTS
|
||||
"Disable some template heavy unit tests (for CI usage)" OFF)
|
||||
"Disable some template heavy unit tests (for CI usage)"
|
||||
OFF)
|
||||
|
||||
# Top level project settings only
|
||||
if(CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
if (CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
set(CTI_CONTINUABLE_WITH_CONCURRENT_JOBS
|
||||
"0"
|
||||
CACHE
|
||||
STRING
|
||||
"Set the number of concurrent compilation jobs (0 = unlimited, for CI usage)"
|
||||
)
|
||||
"0" CACHE STRING
|
||||
"Set the number of concurrent compilation jobs (0 = unlimited, for CI usage)")
|
||||
else()
|
||||
set(CTI_CONTINUABLE_WITH_CONCURRENT_JOBS "0")
|
||||
endif()
|
||||
@ -82,7 +80,7 @@ if(NOT TARGET Threads::Threads)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
if (CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
include(cmake/CMakeLists.txt)
|
||||
add_subdirectory(dep)
|
||||
else()
|
||||
@ -92,7 +90,7 @@ else()
|
||||
endif()
|
||||
|
||||
# continuable-base
|
||||
if(CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
if (CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
add_library(continuable-base INTERFACE)
|
||||
else()
|
||||
add_library(continuable-base INTERFACE IMPORTED GLOBAL)
|
||||
@ -100,16 +98,18 @@ endif()
|
||||
|
||||
add_library(continuable::continuable-base ALIAS continuable-base)
|
||||
|
||||
target_include_directories(
|
||||
continuable-base
|
||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
|
||||
target_include_directories(continuable-base
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
|
||||
target_link_libraries(continuable-base INTERFACE Threads::Threads)
|
||||
target_link_libraries(continuable-base
|
||||
INTERFACE
|
||||
Threads::Threads)
|
||||
|
||||
target_compile_features(
|
||||
continuable-base
|
||||
INTERFACE cxx_alias_templates
|
||||
target_compile_features(continuable-base
|
||||
INTERFACE
|
||||
cxx_alias_templates
|
||||
cxx_auto_type
|
||||
cxx_constexpr
|
||||
cxx_decltype
|
||||
@ -123,33 +123,30 @@ target_compile_features(
|
||||
cxx_trailing_return_types
|
||||
cxx_return_type_deduction)
|
||||
|
||||
if(CTI_CONTINUABLE_WITH_CPP_LATEST)
|
||||
target_compile_features(continuable-base INTERFACE cxx_std_20)
|
||||
if (CTI_CONTINUABLE_WITH_CPP_LATEST)
|
||||
target_compile_features(continuable-base
|
||||
INTERFACE
|
||||
cxx_std_17)
|
||||
endif()
|
||||
|
||||
if(CTI_CONTINUABLE_WITH_COROUTINE)
|
||||
if(NOT CTI_CONTINUABLE_WITH_CPP_LATEST)
|
||||
message(FATAL_ERROR "CTI_CONTINUABLE_WITH_COROUTINE requires "
|
||||
"CTI_CONTINUABLE_WITH_CPP_LATEST!")
|
||||
endif()
|
||||
|
||||
target_compile_options(
|
||||
continuable-base
|
||||
INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/await:strict>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-fcoroutines-ts>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-fcoroutines>)
|
||||
elseif(CTI_CONTINUABLE_WITH_EXPERIMENTAL_COROUTINE)
|
||||
target_compile_options(
|
||||
continuable-base INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/await>
|
||||
if (CTI_CONTINUABLE_WITH_EXPERIMENTAL_COROUTINE)
|
||||
target_compile_options(continuable-base
|
||||
INTERFACE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/await>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-fcoroutines-ts>)
|
||||
endif()
|
||||
|
||||
if(CTI_CONTINUABLE_WITH_UNHANDLED_EXCEPTIONS)
|
||||
target_compile_definitions(continuable-base
|
||||
INTERFACE CONTINUABLE_WITH_UNHANDLED_EXCEPTIONS)
|
||||
INTERFACE
|
||||
CONTINUABLE_WITH_EXPERIMENTAL_COROUTINE)
|
||||
endif()
|
||||
|
||||
if(CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
if (CTI_CONTINUABLE_WITH_UNHANDLED_EXCEPTIONS)
|
||||
target_compile_definitions(continuable-base
|
||||
INTERFACE
|
||||
CONTINUABLE_WITH_UNHANDLED_EXCEPTIONS)
|
||||
endif()
|
||||
|
||||
if (CTI_CONTINUABLE_IS_TOP_LEVEL_PROJECT)
|
||||
add_library(continuable INTERFACE)
|
||||
else()
|
||||
add_library(continuable INTERFACE IMPORTED GLOBAL)
|
||||
@ -157,15 +154,18 @@ endif()
|
||||
|
||||
add_library(continuable::continuable ALIAS continuable)
|
||||
|
||||
target_link_libraries(continuable INTERFACE continuable::continuable-base
|
||||
target_link_libraries(continuable
|
||||
INTERFACE
|
||||
continuable::continuable-base
|
||||
function2::function2)
|
||||
|
||||
if(CTI_CONTINUABLE_WITH_INSTALL)
|
||||
if (CTI_CONTINUABLE_WITH_INSTALL)
|
||||
include(ExternalProject)
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Create an install target: Headers and license files
|
||||
# Create an install target:
|
||||
# Headers and license files
|
||||
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/continuable"
|
||||
DESTINATION "include")
|
||||
install(FILES "LICENSE.txt" DESTINATION .)
|
||||
@ -180,8 +180,7 @@ if(CTI_CONTINUABLE_WITH_INSTALL)
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
# ConfigVersion.cmake
|
||||
configure_package_config_file(
|
||||
"cmake/config.cmake.in"
|
||||
configure_package_config_file("cmake/config.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
# PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR
|
||||
@ -190,17 +189,13 @@ if(CTI_CONTINUABLE_WITH_INSTALL)
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
# Targets.cmake
|
||||
export(
|
||||
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-base
|
||||
export(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-base
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
|
||||
install(
|
||||
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-base
|
||||
EXPORT "${PROJECT_NAME}Targets"
|
||||
INCLUDES
|
||||
DESTINATION "include")
|
||||
install(
|
||||
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-base
|
||||
EXPORT "${PROJECT_NAME}Targets"
|
||||
INCLUDES DESTINATION "include")
|
||||
install(EXPORT "${PROJECT_NAME}Targets"
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
@ -214,8 +209,8 @@ if(CTI_CONTINUABLE_WITH_INSTALL)
|
||||
endif()
|
||||
|
||||
# Testing and examples
|
||||
if(CTI_CONTINUABLE_WITH_TESTS OR CTI_CONTINUABLE_WITH_EXAMPLES)
|
||||
if(MSVC)
|
||||
if (CTI_CONTINUABLE_WITH_TESTS OR CTI_CONTINUABLE_WITH_EXAMPLES)
|
||||
if (MSVC)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
@ -223,11 +218,11 @@ if(CTI_CONTINUABLE_WITH_TESTS OR CTI_CONTINUABLE_WITH_EXAMPLES)
|
||||
|
||||
enable_testing()
|
||||
|
||||
if(CTI_CONTINUABLE_WITH_TESTS)
|
||||
if (CTI_CONTINUABLE_WITH_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
if(CTI_CONTINUABLE_WITH_EXAMPLES)
|
||||
if (CTI_CONTINUABLE_WITH_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://naios.github.io/continuable/changelog.html#changelog-versions-4-0-0"><img alt="Current version" src="https://img.shields.io/badge/Version-4.0.0-0091EA.svg"></a>
|
||||
<a href="https://travis-ci.org/Naios/continuable"><img alt="Travic-CI build status" src="https://travis-ci.org/Naios/continuable.svg?branch=master"></a>
|
||||
<a href="https://ci.appveyor.com/project/Naios/continuable/branch/master"><img alt="AppVeyor CI status" src="https://ci.appveyor.com/api/projects/status/328ta3r5x92f3byv/branch/master?svg=true"></a>
|
||||
<img alt="MIT Licensed" src="https://img.shields.io/badge/License-MIT-00838F.svg">
|
||||
<a href="https://naios.github.io/continuable/"><img alt="Documentation" src="https://img.shields.io/badge/Documentation-Doxygen-26A69A.svg"></a>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
# Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 6c054e98f3f53352d12b6cd46d63b6d404cc044b
|
||||
Subproject commit 8087252a0c3c2f0baad96ddbd6554db17a846376
|
||||
@ -7,7 +7,7 @@
|
||||
https://github.com/Naios/continuable
|
||||
v4.0.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -76,7 +76,7 @@ your personal experience in using the library to improve it.
|
||||
Continuable is licensed under the MIT license:
|
||||
|
||||
>
|
||||
> Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
> Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
https://github.com/Naios/continuable
|
||||
v3.0.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
https://github.com/Naios/continuable
|
||||
v4.0.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -50,22 +50,18 @@ void unexpected_error(cti::exception_t);
|
||||
// Check that the failure was an aborted operation, as expected.
|
||||
void check_aborted_operation(cti::exception_t);
|
||||
|
||||
// Use a strand as executor
|
||||
void using_strand();
|
||||
|
||||
int main(int, char**) {
|
||||
daytime_service();
|
||||
|
||||
successful_async_wait();
|
||||
cancelled_async_wait();
|
||||
|
||||
using_strand();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void daytime_service() {
|
||||
using asio::ip::tcp;
|
||||
|
||||
asio::io_context ioc(1);
|
||||
tcp::resolver resolver(ioc);
|
||||
tcp::socket socket(ioc);
|
||||
@ -150,27 +146,3 @@ void check_aborted_operation(cti::exception_t ex) {
|
||||
puts("Continuation failed due to aborted async operation, as expected.");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto through_post(T& postable) {
|
||||
return [&postable](auto&& work) mutable {
|
||||
asio::post(postable, std::forward<decltype(work)>(work));
|
||||
};
|
||||
}
|
||||
|
||||
void using_strand() {
|
||||
asio::io_context ioc(1);
|
||||
asio::io_context::strand strand(ioc);
|
||||
|
||||
asio::post(strand, cti::use_continuable).then([]() {
|
||||
puts("Dispatched through initiation token");
|
||||
});
|
||||
|
||||
cti::async_on(
|
||||
[]() mutable {
|
||||
puts("Dispatched through executor");
|
||||
},
|
||||
through_post(strand));
|
||||
|
||||
ioc.run();
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
https://github.com/Naios/continuable
|
||||
v4.0.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -47,9 +47,10 @@
|
||||
#include <continuable/detail/utility/traits.hpp>
|
||||
#include <continuable/detail/utility/util.hpp>
|
||||
|
||||
#if defined(CONTINUABLE_HAS_COROUTINE)
|
||||
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
# include <experimental/coroutine>
|
||||
# include <continuable/detail/other/coroutines.hpp>
|
||||
#endif // defined(CONTINUABLE_HAS_COROUTINE)
|
||||
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
|
||||
namespace cti {
|
||||
/// \defgroup Base Base
|
||||
@ -433,21 +434,6 @@ public:
|
||||
std::forward<E>(executor));
|
||||
}
|
||||
|
||||
/// Returns a continuable_base which continues its invocation through the
|
||||
/// given executor.
|
||||
///
|
||||
/// \returns Returns a continuable_base of the same type.
|
||||
///
|
||||
/// \since 4.2.0
|
||||
template <typename E>
|
||||
auto via(E&& executor) && {
|
||||
return std::move(*this).next(
|
||||
[](auto&&... args) {
|
||||
return make_result(std::forward<decltype(args)>(args)...);
|
||||
},
|
||||
std::forward<E>(executor));
|
||||
}
|
||||
|
||||
/// Returns a continuable_base which will have its signature converted
|
||||
/// to the given Args.
|
||||
///
|
||||
@ -714,7 +700,7 @@ public:
|
||||
}
|
||||
|
||||
/// \cond false
|
||||
#if defined(CONTINUABLE_HAS_COROUTINE)
|
||||
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
/// \endcond
|
||||
/// Implements the operator for awaiting on continuables using `co_await`.
|
||||
///
|
||||
@ -780,7 +766,7 @@ public:
|
||||
return detail::awaiting::create_awaiter(std::move(*this).finish());
|
||||
}
|
||||
/// \cond false
|
||||
#endif // defined(CONTINUABLE_HAS_COROUTINE)
|
||||
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
/// \endcond
|
||||
|
||||
private:
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -39,9 +39,11 @@
|
||||
# include <exception>
|
||||
#endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
|
||||
#if defined(CONTINUABLE_HAS_COROUTINE)
|
||||
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
# include <continuable/detail/other/coroutines.hpp>
|
||||
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
|
||||
#if defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
namespace cti {
|
||||
# if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
/// Is thrown from co_await expressions if the awaited continuable is canceled
|
||||
@ -76,9 +78,7 @@ using await_canceled_exception = detail::awaiting::await_canceled_exception;
|
||||
// As far as I know there is no other way to implement this specialization...
|
||||
// NOLINTNEXTLINE(cert-dcl58-cpp)
|
||||
namespace std {
|
||||
# if defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
namespace experimental {
|
||||
# endif // defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
template <typename Data, typename... Args, typename... FunctionArgs>
|
||||
struct coroutine_traits<
|
||||
cti::continuable_base<Data, cti::detail::identity<Args...>>,
|
||||
@ -87,11 +87,9 @@ struct coroutine_traits<
|
||||
using promise_type = cti::detail::awaiting::promise_type<
|
||||
cti::continuable<Args...>, cti::promise<Args...>, Args...>;
|
||||
};
|
||||
# if defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
} // namespace experimental
|
||||
# endif // defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
} // namespace std
|
||||
/// \endcond
|
||||
#endif // defined(CONTINUABLE_HAS_COROUTINE)
|
||||
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
|
||||
#endif // CONTINUABLE_COROUTINE_HPP_INCLUDED
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -147,24 +147,24 @@ struct connection_finalizer<connection_strategy_seq_tag> {
|
||||
template <typename Connection>
|
||||
static auto finalize(Connection&& connection, util::ownership ownership) {
|
||||
|
||||
auto res =
|
||||
auto result =
|
||||
aggregated::box_continuables(std::forward<Connection>(connection));
|
||||
|
||||
auto signature = aggregated::hint_of_data<decltype(res)>();
|
||||
auto signature = aggregated::hint_of_data<decltype(result)>();
|
||||
|
||||
return base::attorney::create_from(
|
||||
[res = std::move(res)](auto&& callback) mutable {
|
||||
[result = std::move(result)](auto&& callback) mutable {
|
||||
// The data from which the visitor is constructed in-place
|
||||
using data_t =
|
||||
seq::sequential_dispatch_data<std::decay_t<decltype(callback)>,
|
||||
std::decay_t<decltype(res)>>;
|
||||
std::decay_t<decltype(result)>>;
|
||||
|
||||
// The visitor type
|
||||
using visitor_t = seq::sequential_dispatch_visitor<data_t>;
|
||||
|
||||
traverse_pack_async(async_traverse_in_place_tag<visitor_t>{},
|
||||
data_t{std::forward<decltype(callback)>(callback),
|
||||
std::move(res)});
|
||||
std::move(result)});
|
||||
},
|
||||
signature, std::move(ownership));
|
||||
}
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
62
include/continuable/detail/external/asio.hpp
vendored
62
include/continuable/detail/external/asio.hpp
vendored
@ -4,9 +4,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -109,50 +109,31 @@ using system_error_t = ::boost::system::system_error;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Binds `promise` to the first argument of a continuable resolver, giving it
|
||||
// the signature of an ASIO handler.
|
||||
template <typename Promise, typename Token>
|
||||
class promise_resolver {
|
||||
public:
|
||||
explicit promise_resolver(Promise promise, Token token)
|
||||
: promise_(std::move(promise))
|
||||
, token_(std::move(token)) {}
|
||||
|
||||
template <typename... T>
|
||||
void operator()(T&&... args) noexcept {
|
||||
promise_.set_value(std::forward<T>(args)...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void operator()(error_code_t e, T&&... args) noexcept {
|
||||
auto promise_resolver_handler(Promise&& promise, Token&& token) noexcept {
|
||||
return [promise = std::forward<Promise>(promise),
|
||||
token = std::forward<Token>(token)](error_code_t e,
|
||||
auto&&... args) mutable noexcept {
|
||||
if (e) {
|
||||
if (!token_.is_ignored(e)) {
|
||||
if (token_.is_cancellation(e)) {
|
||||
promise_.set_canceled();
|
||||
if (!token.is_ignored(e)) {
|
||||
if (token.is_cancellation(e)) {
|
||||
promise.set_canceled();
|
||||
return;
|
||||
} else {
|
||||
#if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
promise_.set_exception(
|
||||
promise.set_exception(
|
||||
std::make_exception_ptr(system_error_t(std::move(e))));
|
||||
#else
|
||||
promise_.set_exception(exception_t(e.value(), e.category()));
|
||||
promise.set_exception(exception_t(e.value(), e.category()));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
promise_.set_value(std::forward<T>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
Promise promise_;
|
||||
Token token_;
|
||||
};
|
||||
|
||||
// Binds `promise` to the first argument of a continuable resolver, giving it
|
||||
// the signature of an ASIO handler.
|
||||
template <typename Promise, typename Token>
|
||||
auto promise_resolver_handler(Promise&& promise, Token&& token) noexcept {
|
||||
return promise_resolver<std::decay_t<Promise>, std::decay_t<Token>>(
|
||||
std::forward<Promise>(promise), std::forward<Token>(token));
|
||||
promise.set_value(std::forward<decltype(args)>(args)...);
|
||||
};
|
||||
}
|
||||
|
||||
// Helper struct wrapping a call to `cti::make_continuable` and, if needed,
|
||||
@ -160,19 +141,6 @@ auto promise_resolver_handler(Promise&& promise, Token&& token) noexcept {
|
||||
template <typename Signature>
|
||||
struct initiate_make_continuable;
|
||||
|
||||
template <typename... Args>
|
||||
struct initiate_make_continuable<void(Args...)> {
|
||||
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
||||
using erased_return_type = continuable<Args...>;
|
||||
#endif
|
||||
|
||||
template <typename Continuation>
|
||||
auto operator()(Continuation&& continuation) {
|
||||
return base::attorney::create_from(std::forward<Continuation>(continuation),
|
||||
identity<Args...>{}, util::ownership{});
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
struct initiate_make_continuable<void(error_code_t, Args...)> {
|
||||
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -33,19 +33,19 @@
|
||||
|
||||
// Defines CONTINUABLE_WITH_NO_EXCEPTIONS when exception support is disabled
|
||||
#ifndef CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
# if defined(_MSC_VER)
|
||||
# if !defined(_HAS_EXCEPTIONS) || (_HAS_EXCEPTIONS == 0)
|
||||
# define CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
# endif
|
||||
# elif defined(__clang__)
|
||||
# if !(__EXCEPTIONS && __has_feature(cxx_exceptions))
|
||||
# define CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
# endif
|
||||
# elif defined(__GNUC__)
|
||||
# if !__EXCEPTIONS
|
||||
# define CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
# endif
|
||||
# endif
|
||||
#if defined(_MSC_VER)
|
||||
#if !defined(_HAS_EXCEPTIONS) || (_HAS_EXCEPTIONS == 0)
|
||||
#define CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
#endif
|
||||
#elif defined(__clang__)
|
||||
#if !(__EXCEPTIONS && __has_feature(cxx_exceptions))
|
||||
#define CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
#if !__EXCEPTIONS
|
||||
#define CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
#endif
|
||||
#endif
|
||||
#endif // CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
|
||||
// clang-format off
|
||||
@ -86,42 +86,24 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Automatically detects support for coroutines.
|
||||
// Parts of this detection mechanism were adapted from boost::asio,
|
||||
// with support added for experimental coroutines.
|
||||
#if !defined(CONTINUABLE_HAS_DISABLED_COROUTINE) \
|
||||
&& !defined(CONTINUABLE_HAS_COROUTINE)
|
||||
/// Usually this is enabled by the CMake project
|
||||
#if !defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
/// Define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE when
|
||||
/// CONTINUABLE_WITH_EXPERIMENTAL_COROUTINE is defined.
|
||||
#if defined(CONTINUABLE_WITH_EXPERIMENTAL_COROUTINE)
|
||||
#define CONTINUABLE_HAS_COROUTINE 1
|
||||
#elif defined(CONTINUABLE_WITH_COROUTINE)
|
||||
#define CONTINUABLE_HAS_COROUTINE 1
|
||||
#define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE 1
|
||||
#elif defined(_MSC_VER) // Visual Studio
|
||||
#if (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705)
|
||||
#define CONTINUABLE_HAS_COROUTINE 1
|
||||
#elif _MSC_FULL_VER >= 190023506
|
||||
#define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
#elif defined(_MSC_VER)
|
||||
#if _MSC_FULL_VER >= 190023506
|
||||
#if defined(_RESUMABLE_FUNCTIONS_SUPPORTED)
|
||||
#define CONTINUABLE_HAS_COROUTINE 1
|
||||
#define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE 1
|
||||
#define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
#endif // defined(_RESUMABLE_FUNCTIONS_SUPPORTED)
|
||||
#endif // _MSC_FULL_VER >= 190023506
|
||||
#elif defined(__clang__) // Clang
|
||||
#if defined(__cpp_coroutines) && (__cpp_coroutines >= 201703L)
|
||||
#define CONTINUABLE_HAS_COROUTINE 1
|
||||
#if defined(_LIBCPP_EXPERIMENTAL_COROUTINE)
|
||||
#define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE 1
|
||||
#endif
|
||||
#endif // defined(__cpp_coroutines) && (__cpp_coroutines >= 201703L)
|
||||
#elif defined(__GNUC__) // GCC
|
||||
#if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
|
||||
#if __has_include(<coroutine>)
|
||||
#define CONTINUABLE_HAS_COROUTINE 1
|
||||
#endif // __has_include(<coroutine>)
|
||||
#endif // (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__clang__)
|
||||
#if defined(__cpp_coroutines) && (__cpp_coroutines >= 201707)
|
||||
#define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
#endif // defined(__cpp_coroutines) && (__cpp_coroutines >= 201707)
|
||||
#endif // defined(__clang__)
|
||||
#endif // !defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
|
||||
/// Define CONTINUABLE_HAS_EXCEPTIONS when exceptions are used
|
||||
#if !defined(CONTINUABLE_WITH_CUSTOM_ERROR_TYPE) && \
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
#include <experimental/coroutine>
|
||||
#include <continuable/continuable-primitives.hpp>
|
||||
#include <continuable/continuable-result.hpp>
|
||||
#include <continuable/detail/core/annotation.hpp>
|
||||
@ -47,26 +48,13 @@
|
||||
# include <exception>
|
||||
#endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
|
||||
#if defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
# include <experimental/coroutine>
|
||||
#elif defined(CONTINUABLE_HAS_COROUTINE)
|
||||
# include <coroutine>
|
||||
#endif
|
||||
|
||||
#if defined(CONTINUABLE_HAS_COROUTINE)
|
||||
namespace cti {
|
||||
namespace detail {
|
||||
namespace awaiting {
|
||||
/// We import the coroutine handle in our namespace
|
||||
# if defined(CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||
using std::experimental::coroutine_handle;
|
||||
using std::experimental::suspend_never;
|
||||
# else
|
||||
using std::coroutine_handle;
|
||||
using std::suspend_never;
|
||||
# endif
|
||||
|
||||
# if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
#if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
class await_canceled_exception : public std::exception {
|
||||
public:
|
||||
await_canceled_exception() noexcept = default;
|
||||
@ -75,7 +63,7 @@ public:
|
||||
return "co_await canceled due to cancellation of the continuation";
|
||||
}
|
||||
};
|
||||
# endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
#endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
|
||||
template <typename T>
|
||||
struct result_from_identity;
|
||||
@ -96,16 +84,6 @@ class awaitable {
|
||||
/// A cache which is used to pass the result of the continuation
|
||||
/// to the coroutine.
|
||||
result_t result_;
|
||||
/// Enumeration that represents the suspension state of the awaitable.
|
||||
enum class state : std::uint8_t {
|
||||
suspended,
|
||||
pending,
|
||||
resolved,
|
||||
};
|
||||
/// An atomic that specifies whether the awaitable has suspended or not.
|
||||
/// Allows to perform symmetric transfer on continuables that are
|
||||
/// immediately resolved.
|
||||
std::atomic<state> state_{state::pending};
|
||||
|
||||
public:
|
||||
explicit constexpr awaitable(Continuable&& continuable)
|
||||
@ -127,27 +105,16 @@ public:
|
||||
|
||||
/// Suspend the current context
|
||||
// TODO Convert this to an r-value function once possible
|
||||
bool await_suspend(coroutine_handle<> h) {
|
||||
void await_suspend(coroutine_handle<> h) {
|
||||
assert(result_.is_empty());
|
||||
// Forward every result to the current awaitable
|
||||
std::move(continuable_)
|
||||
.next([h, this](auto&&... args) mutable {
|
||||
assert(result_.is_empty());
|
||||
result_ = result_t::from(std::forward<decltype(args)>(args)...);
|
||||
|
||||
// If true, it means that the promise was suspended (i.e., the
|
||||
// awaitable await_suspend method has already returned). That
|
||||
// means we must call the resume coroutine from the continuation
|
||||
// chain.
|
||||
if (state_.exchange(state::resolved, std::memory_order_acq_rel) ==
|
||||
state::suspended) {
|
||||
return h.resume();
|
||||
}
|
||||
h.resume();
|
||||
})
|
||||
.done();
|
||||
|
||||
return state_.exchange(state::suspended, std::memory_order_acq_rel) !=
|
||||
state::resolved;
|
||||
}
|
||||
|
||||
/// Resume the coroutine represented by the handle
|
||||
@ -159,16 +126,16 @@ public:
|
||||
|
||||
assert(result_.is_exception());
|
||||
|
||||
# if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
#if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
if (exception_t e = result_.get_exception()) {
|
||||
std::rethrow_exception(std::move(e));
|
||||
} else {
|
||||
throw await_canceled_exception();
|
||||
}
|
||||
# else // CONTINUABLE_HAS_EXCEPTIONS
|
||||
#else // CONTINUABLE_HAS_EXCEPTIONS
|
||||
// Returning error types from co_await isn't supported!
|
||||
CTI_DETAIL_TRAP();
|
||||
# endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
#endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
}
|
||||
};
|
||||
|
||||
@ -246,12 +213,12 @@ struct promise_type
|
||||
return {handle_};
|
||||
}
|
||||
|
||||
suspend_never final_suspend() noexcept {
|
||||
std::experimental::suspend_never final_suspend() {
|
||||
return {};
|
||||
}
|
||||
|
||||
void unhandled_exception() noexcept {
|
||||
# if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
#if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
try {
|
||||
std::rethrow_exception(std::current_exception());
|
||||
} catch (await_canceled_exception const&) {
|
||||
@ -259,15 +226,14 @@ struct promise_type
|
||||
} catch (...) {
|
||||
promise_.set_exception(std::current_exception());
|
||||
}
|
||||
# else // CONTINUABLE_HAS_EXCEPTIONS
|
||||
#else // CONTINUABLE_HAS_EXCEPTIONS
|
||||
// Returning exception types from a coroutine isn't supported
|
||||
CTI_DETAIL_TRAP();
|
||||
# endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
#endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
}
|
||||
};
|
||||
} // namespace awaiting
|
||||
} // namespace detail
|
||||
} // namespace cti
|
||||
#endif // defined(CONTINUABLE_HAS_COROUTINE)
|
||||
|
||||
#endif // CONTINUABLE_DETAIL_UTIL_HPP_INCLUDED
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -72,52 +72,6 @@ struct sync_trait<identity<Args...>> {
|
||||
using lock_t = std::unique_lock<std::mutex>;
|
||||
using condition_variable_t = std::condition_variable;
|
||||
|
||||
template <typename Result>
|
||||
struct unsafe_unlocker {
|
||||
explicit unsafe_unlocker(std::atomic_bool* ready, condition_variable_t* cv,
|
||||
std::mutex* mutex, Result* result)
|
||||
: ready_(ready)
|
||||
, cv_(cv)
|
||||
, mutex_(mutex)
|
||||
, result_(result) {}
|
||||
|
||||
unsafe_unlocker(unsafe_unlocker const&) = delete;
|
||||
unsafe_unlocker(unsafe_unlocker&&) = default;
|
||||
unsafe_unlocker& operator=(unsafe_unlocker const&) = delete;
|
||||
unsafe_unlocker& operator=(unsafe_unlocker&&) = default;
|
||||
|
||||
~unsafe_unlocker() {
|
||||
unlock(Result::empty());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(Args&&... args) {
|
||||
unlock(Result::from(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
void unlock(Result&& result) {
|
||||
if (!ownership_.is_acquired()) {
|
||||
return;
|
||||
}
|
||||
ownership_.release();
|
||||
|
||||
lock_t lock(*mutex_);
|
||||
|
||||
*result_ = std::move(result);
|
||||
|
||||
assert(!ready_->load(std::memory_order_acquire));
|
||||
ready_->store(true, std::memory_order_release);
|
||||
|
||||
cv_->notify_all();
|
||||
}
|
||||
|
||||
std::atomic_bool* ready_;
|
||||
condition_variable_t* cv_;
|
||||
std::mutex* mutex_;
|
||||
Result* result_;
|
||||
util::ownership ownership_;
|
||||
};
|
||||
|
||||
template <typename Data, typename Annotation,
|
||||
typename Result = typename sync_trait<Annotation>::result_t>
|
||||
Result wait_relaxed(continuable_base<Data, Annotation>&& continuable) {
|
||||
@ -130,22 +84,23 @@ Result wait_relaxed(continuable_base<Data, Annotation>&& continuable) {
|
||||
condition_variable_t cv;
|
||||
std::mutex cv_mutex;
|
||||
|
||||
std::atomic_bool ready{false};
|
||||
bool ready{false};
|
||||
Result sync_result;
|
||||
|
||||
std::move(continuable)
|
||||
.next(unsafe_unlocker<Result>{
|
||||
&ready,
|
||||
&cv,
|
||||
&cv_mutex,
|
||||
&sync_result,
|
||||
.next([&](auto&&... args) {
|
||||
sync_result = Result::from(std::forward<decltype(args)>(args)...);
|
||||
|
||||
lock_t lock(cv_mutex);
|
||||
ready = true;
|
||||
cv.notify_all();
|
||||
})
|
||||
.done();
|
||||
|
||||
lock_t lock(cv_mutex);
|
||||
if (!ready.load(std::memory_order_acquire)) {
|
||||
if (!ready) {
|
||||
cv.wait(lock, [&] {
|
||||
return ready.load(std::memory_order_acquire);
|
||||
return ready;
|
||||
});
|
||||
}
|
||||
|
||||
@ -162,15 +117,14 @@ auto wait_and_unpack(continuable_base<Data, Annotation>&& continuable) {
|
||||
#if defined(CONTINUABLE_HAS_EXCEPTIONS)
|
||||
if (sync_result.is_value()) {
|
||||
return std::move(sync_result).get_value();
|
||||
} else if (sync_result.is_exception()) {
|
||||
if (sync_result.is_exception()) {
|
||||
} else {
|
||||
assert(sync_result.is_exception());
|
||||
if (exception_t e = sync_result.get_exception()) {
|
||||
std::rethrow_exception(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
throw wait_transform_canceled_exception();
|
||||
}
|
||||
}
|
||||
#else
|
||||
return sync_result;
|
||||
#endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
@ -185,47 +139,6 @@ struct wait_frame {
|
||||
Result sync_result;
|
||||
};
|
||||
|
||||
template <typename Result>
|
||||
struct unlocker {
|
||||
unlocker(unlocker const&) = delete;
|
||||
unlocker(unlocker&&) = default;
|
||||
unlocker& operator=(unlocker const&) = delete;
|
||||
unlocker& operator=(unlocker&&) = default;
|
||||
|
||||
explicit unlocker(std::weak_ptr<wait_frame<Result>> frame)
|
||||
: frame_(std::move(frame)) {}
|
||||
|
||||
~unlocker() {
|
||||
unlock(Result::empty());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void operator()(Args&&... args) {
|
||||
unlock(Result::from(std::forward<decltype(args)>(args)...));
|
||||
}
|
||||
|
||||
void unlock(Result&& result) {
|
||||
if (!ownership_.is_acquired()) {
|
||||
return;
|
||||
}
|
||||
ownership_.release();
|
||||
|
||||
if (auto locked = frame_.lock()) {
|
||||
{
|
||||
std::lock_guard<std::mutex> rw_lock(locked->rw_mutex);
|
||||
assert(!locked->ready.load(std::memory_order_acquire));
|
||||
locked->sync_result = std::move(result);
|
||||
}
|
||||
|
||||
locked->ready.store(true, std::memory_order_release);
|
||||
locked->cv.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
std::weak_ptr<wait_frame<Result>> frame_;
|
||||
util::ownership ownership_;
|
||||
};
|
||||
|
||||
template <typename Data, typename Annotation, typename Waiter,
|
||||
typename Result = typename sync_trait<Annotation>::result_t>
|
||||
Result wait_unsafe(continuable_base<Data, Annotation>&& continuable,
|
||||
@ -241,7 +154,18 @@ Result wait_unsafe(continuable_base<Data, Annotation>&& continuable,
|
||||
auto frame = std::make_shared<frame_t>();
|
||||
|
||||
std::move(continuable)
|
||||
.next(unlocker<Result>{std::weak_ptr<frame_t>(frame)})
|
||||
.next([frame = std::weak_ptr<frame_t>(frame)](auto&&... args) {
|
||||
if (auto locked = frame.lock()) {
|
||||
{
|
||||
std::lock_guard<std::mutex> rw_lock(locked->rw_mutex);
|
||||
locked->sync_result = Result::from(
|
||||
std::forward<decltype(args)>(args)...);
|
||||
}
|
||||
|
||||
locked->ready.store(true, std::memory_order_release);
|
||||
locked->cv.notify_all();
|
||||
}
|
||||
})
|
||||
.done();
|
||||
|
||||
if (!frame->ready.load(std::memory_order_acquire)) {
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
4
include/continuable/external/asio.hpp
vendored
4
include/continuable/external/asio.hpp
vendored
@ -4,9 +4,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
4
include/continuable/external/gtest.hpp
vendored
4
include/continuable/external/gtest.hpp
vendored
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
\_,(_)| | | || ||_|(_||_)|(/_
|
||||
|
||||
https://github.com/Naios/continuable
|
||||
v4.2.0
|
||||
v4.1.0
|
||||
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -115,50 +115,11 @@ TYPED_TEST(single_dimension_tests, wait_test_exception) {
|
||||
test_exception);
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, wait_test_unlocked) {
|
||||
make_continuable<void>([&](promise<> p) {
|
||||
p.set_value();
|
||||
}).apply(transforms::wait());
|
||||
|
||||
ASSERT_TRUE(true);
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, wait_test_cancellation) {
|
||||
ASSERT_THROW(make_cancelling_continuable<void>().apply(
|
||||
cti::transforms::wait()),
|
||||
transforms::wait_transform_canceled_exception);
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests,
|
||||
wait_test_exception_unlocked_void_failure_handle) {
|
||||
ASSERT_THROW(make_exceptional_continuable<void>(supply_test_exception())
|
||||
.fail([](exception_t) {})
|
||||
.apply(transforms::wait()),
|
||||
transforms::wait_transform_canceled_exception);
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, wait_test_unlocked_empty_result) {
|
||||
ASSERT_THROW(async([]() -> result<> {
|
||||
return empty_result();
|
||||
}).apply(transforms::wait()),
|
||||
transforms::wait_transform_canceled_exception);
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests,
|
||||
wait_for_test_exception_unlocked_void_failure_handle) {
|
||||
ASSERT_TRUE(make_exceptional_continuable<void>(supply_test_exception())
|
||||
.fail([](exception_t) {})
|
||||
.apply(transforms::wait_for(24h))
|
||||
.is_empty());
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, wait_for_test_unlocked_empty_result) {
|
||||
ASSERT_TRUE(async([]() -> result<> {
|
||||
return empty_result();
|
||||
})
|
||||
.apply(transforms::wait_for(24h))
|
||||
.is_empty());
|
||||
}
|
||||
#endif // CONTINUABLE_HAS_EXCEPTIONS
|
||||
|
||||
TYPED_TEST(single_dimension_tests, wait_for_test_sync) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -24,8 +24,7 @@
|
||||
#include <test-continuable.hpp>
|
||||
|
||||
#include <continuable/detail/features.hpp>
|
||||
|
||||
#ifdef CONTINUABLE_HAS_COROUTINE
|
||||
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
|
||||
# ifndef CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
# include <exception>
|
||||
@ -169,78 +168,6 @@ TYPED_TEST(single_dimension_tests, are_awaitable_with_cancellation_from_coro) {
|
||||
ASSERT_ASYNC_CANCELLATION(resolve_coro_canceled(supply))
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
cti::continuable<> test_symmetric_transfer(S&& supplier) {
|
||||
// If symmetric transfer is not working properly, large
|
||||
// loops will quickly cause stack overflows.
|
||||
for (size_t index = 0; index < 10000; index++) {
|
||||
co_await supplier();
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_symmetric_transferable) {
|
||||
auto const& supply = [&]() {
|
||||
return cti::make_continuable<int>([](auto&& promise) {
|
||||
promise.set_value(0);
|
||||
});
|
||||
};
|
||||
|
||||
ASSERT_ASYNC_COMPLETION(test_symmetric_transfer(supply));
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_symmetric_transferable_type_erased) {
|
||||
auto const& supply = [&]() -> cti::continuable<int> {
|
||||
return cti::make_continuable<int>([](auto&& promise) {
|
||||
promise.set_value(0);
|
||||
});
|
||||
};
|
||||
|
||||
ASSERT_ASYNC_COMPLETION(test_symmetric_transfer(supply));
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests,
|
||||
are_symmetric_transferable_using_make_ready) {
|
||||
auto const& supply = [&]() {
|
||||
return cti::make_ready_continuable<int>(0);
|
||||
};
|
||||
|
||||
ASSERT_ASYNC_COMPLETION(test_symmetric_transfer(supply));
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests,
|
||||
are_symmetric_transferable_using_type_erased_make_ready) {
|
||||
auto const& supply = [&]() -> cti::continuable<int> {
|
||||
return cti::make_ready_continuable<int>(0);
|
||||
};
|
||||
|
||||
ASSERT_ASYNC_COMPLETION(test_symmetric_transfer(supply));
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_symmetric_transferable_using_type_erased_from_thread) {
|
||||
auto const& supply = [&]() -> cti::continuable<int> {
|
||||
return cti::make_continuable<int>([](auto&& promise) {
|
||||
std::async(std::launch::async, std::forward<decltype(promise)>(promise), 0);
|
||||
});
|
||||
};
|
||||
|
||||
ASSERT_ASYNC_COMPLETION(test_symmetric_transfer(supply));
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_symmetric_transferable_except) {
|
||||
size_t count = 0;
|
||||
auto const& supply = [&]() -> cti::continuable<int> {
|
||||
// NOTE: The symmetric transfer loop does 10000 iterations.
|
||||
if(++count == 5000) {
|
||||
return cti::make_exceptional_continuable<int>(
|
||||
std::make_exception_ptr(std::runtime_error("Failed")));
|
||||
}
|
||||
return cti::make_ready_continuable<int>(0);
|
||||
};
|
||||
|
||||
ASSERT_ASYNC_EXCEPTION_COMPLETION(test_symmetric_transfer(supply));
|
||||
}
|
||||
|
||||
# endif // CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
|
||||
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -47,26 +47,6 @@ TYPED_TEST(single_dimension_tests, are_executor_dispatchable) {
|
||||
ASSERT_ASYNC_COMPLETION(std::move(chain));
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_executor_dispatchable_via) {
|
||||
bool invoked = false;
|
||||
auto executor = [&](auto&& work) {
|
||||
// We can move the worker object
|
||||
auto local = std::forward<decltype(work)>(work);
|
||||
ASSERT_FALSE(invoked);
|
||||
// We can invoke the worker object
|
||||
std::move(local)();
|
||||
};
|
||||
|
||||
auto chain = this->supply().via(executor).then([&] {
|
||||
ASSERT_FALSE(invoked);
|
||||
invoked = true;
|
||||
});
|
||||
|
||||
ASSERT_ASYNC_COMPLETION(std::move(chain));
|
||||
|
||||
ASSERT_TRUE(invoked);
|
||||
}
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_executor_exception_resolveable) {
|
||||
auto executor = [&](auto&& work) {
|
||||
std::forward<decltype(work)>(work).set_exception(supply_test_exception());
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
Copyright(c) 2015 - 2022 Denis Blank <denis.blank at outlook dot com>
|
||||
Copyright(c) 2015 - 2020 Denis Blank <denis.blank at outlook dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user