mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Initial work on corooutine/await support
This commit is contained in:
parent
1c0c17f699
commit
26ff6312ed
@ -10,6 +10,7 @@ if (NOT DEFINED CONTINUABLE_UNIT_TESTS
|
|||||||
set(CONTINUABLE_UNIT_TESTS ON)
|
set(CONTINUABLE_UNIT_TESTS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(cmake/CMakeLists.txt)
|
||||||
add_subdirectory(dep)
|
add_subdirectory(dep)
|
||||||
|
|
||||||
# continuable-base
|
# continuable-base
|
||||||
@ -23,7 +24,8 @@ target_include_directories(continuable-base
|
|||||||
|
|
||||||
target_link_libraries(continuable-base
|
target_link_libraries(continuable-base
|
||||||
INTERFACE
|
INTERFACE
|
||||||
Threads::Threads)
|
Threads::Threads
|
||||||
|
continuable-coroutines)
|
||||||
|
|
||||||
target_compile_features(continuable-base
|
target_compile_features(continuable-base
|
||||||
INTERFACE
|
INTERFACE
|
||||||
@ -50,7 +52,7 @@ target_link_libraries(continuable
|
|||||||
function2)
|
function2)
|
||||||
|
|
||||||
# Create an install target
|
# Create an install target
|
||||||
install(TARGETS continuable-base continuable
|
install(TARGETS continuable-coroutines continuable-base continuable
|
||||||
EXPORT continuable-config
|
EXPORT continuable-config
|
||||||
INCLUDES DESTINATION include)
|
INCLUDES DESTINATION include)
|
||||||
|
|
||||||
@ -92,8 +94,6 @@ if (CONTINUABLE_UNIT_TESTS)
|
|||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
include(cmake/CMakeLists.txt)
|
|
||||||
|
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
add_library(continuable-features-flags INTERFACE)
|
add_library(continuable-features-flags INTERFACE)
|
||||||
add_library(continuable-features-warnings INTERFACE)
|
add_library(continuable-features-warnings INTERFACE)
|
||||||
add_library(continuable-features-noexcept INTERFACE)
|
add_library(continuable-features-noexcept INTERFACE)
|
||||||
|
add_library(continuable-coroutines INTERFACE)
|
||||||
|
|
||||||
include(cmake/configure_compiler.cmake)
|
include(cmake/configure_compiler.cmake)
|
||||||
|
|||||||
@ -5,6 +5,16 @@ target_compile_options(continuable-features-warnings
|
|||||||
-pedantic
|
-pedantic
|
||||||
-Wextra)
|
-Wextra)
|
||||||
|
|
||||||
|
if (WITH_COROUTINES)
|
||||||
|
target_compile_options(continuable-coroutines
|
||||||
|
INTERFACE
|
||||||
|
-fcoroutines-ts)
|
||||||
|
|
||||||
|
target_compile_definitions(continuable-coroutines
|
||||||
|
INTERFACE
|
||||||
|
-DCONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (TESTS_NO_EXCEPTIONS)
|
if (TESTS_NO_EXCEPTIONS)
|
||||||
target_compile_options(continuable-features-noexcept
|
target_compile_options(continuable-features-noexcept
|
||||||
INTERFACE
|
INTERFACE
|
||||||
@ -12,4 +22,3 @@ if (TESTS_NO_EXCEPTIONS)
|
|||||||
|
|
||||||
message(STATUS "Clang: Disabled exceptions")
|
message(STATUS "Clang: Disabled exceptions")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,16 @@ target_compile_options(continuable-features-warnings
|
|||||||
INTERFACE
|
INTERFACE
|
||||||
/W4)
|
/W4)
|
||||||
|
|
||||||
|
if (WITH_COROUTINES)
|
||||||
|
target_compile_options(continuable-coroutines
|
||||||
|
INTERFACE
|
||||||
|
/await)
|
||||||
|
|
||||||
|
target_compile_definitions(continuable-coroutines
|
||||||
|
INTERFACE
|
||||||
|
-DCONTINUABLE_HAS_EXPERIMENTAL_COROUTINE)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (TESTS_NO_EXCEPTIONS)
|
if (TESTS_NO_EXCEPTIONS)
|
||||||
target_compile_definitions(continuable-features-noexcept
|
target_compile_definitions(continuable-features-noexcept
|
||||||
INTERFACE
|
INTERFACE
|
||||||
|
|||||||
@ -503,6 +503,22 @@ public:
|
|||||||
return std::move(*this);
|
return std::move(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
|
bool is_ready() const noexcept {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void await_suspend(detail::types::coroutine_handle<> h) && {
|
||||||
|
|
||||||
|
h.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto await_resume() {
|
||||||
|
// if ec throw
|
||||||
|
// return n;
|
||||||
|
}
|
||||||
|
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void release() noexcept {
|
void release() noexcept {
|
||||||
ownership_.release();
|
ownership_.release();
|
||||||
|
|||||||
@ -52,4 +52,7 @@
|
|||||||
/// TODO Enable this
|
/// TODO Enable this
|
||||||
#undef CONTINUABLE_HAS_CXX17_FOLD_EXPRESSION
|
#undef CONTINUABLE_HAS_CXX17_FOLD_EXPRESSION
|
||||||
|
|
||||||
|
/// This is enabled by the CMake project
|
||||||
|
// #undef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
|
|
||||||
#endif // CONTINUABLE_DETAIL_FEATURES_HPP_INCLUDED__
|
#endif // CONTINUABLE_DETAIL_FEATURES_HPP_INCLUDED__
|
||||||
|
|||||||
@ -39,6 +39,10 @@
|
|||||||
#endif // CONTINUABLE_WITH_NO_EXCEPTIONS
|
#endif // CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||||
#endif // CONTINUABLE_WITH_CUSTOM_ERROR_TYPE
|
#endif // CONTINUABLE_WITH_CUSTOM_ERROR_TYPE
|
||||||
|
|
||||||
|
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
|
#include <experimental/coroutine>
|
||||||
|
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
|
|
||||||
#include <continuable/continuable-api.hpp>
|
#include <continuable/continuable-api.hpp>
|
||||||
#include <continuable/detail/features.hpp>
|
#include <continuable/detail/features.hpp>
|
||||||
|
|
||||||
@ -62,6 +66,10 @@ using error_type = std::error_condition;
|
|||||||
struct this_thread_executor_tag {};
|
struct this_thread_executor_tag {};
|
||||||
/// A tag which is used to continue with an error
|
/// A tag which is used to continue with an error
|
||||||
struct dispatch_error_tag {};
|
struct dispatch_error_tag {};
|
||||||
|
|
||||||
|
#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
|
using std::experimental::coroutine_handle;
|
||||||
|
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||||
} // namespace types
|
} // namespace types
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user