加协程
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
|
||||
namespace pscoro::asio_glue
|
||||
namespace ucoro::asio_glue
|
||||
{
|
||||
template<typename T>
|
||||
struct asio_awaitable_state
|
||||
@@ -64,7 +64,7 @@ namespace pscoro::asio_glue
|
||||
{
|
||||
boost::asio::any_io_executor executor;
|
||||
|
||||
if constexpr (pscoro::concepts::awaitable_promise_type<PromiseType>)
|
||||
if constexpr (ucoro::concepts::awaitable_promise_type<PromiseType>)
|
||||
{
|
||||
if (continue_handle.promise().local_)
|
||||
{
|
||||
@@ -139,13 +139,13 @@ namespace pscoro::asio_glue
|
||||
struct initiate_do_invoke_ucoro_awaitable
|
||||
{
|
||||
template<typename Handler>
|
||||
void operator()(Handler&& handler, pscoro::awaitable<T> ucoro_awaitable) const
|
||||
void operator()(Handler&& handler, ucoro::awaitable<T> ucoro_awaitable) const
|
||||
{
|
||||
auto executor = boost::asio::get_associated_executor(handler);
|
||||
|
||||
if constexpr (std::is_void_v<T>)
|
||||
{
|
||||
auto task = [handler = std::move(handler), ucoro_awaitable = std::move(ucoro_awaitable)]() mutable -> pscoro::awaitable<void>
|
||||
auto task = [handler = std::move(handler), ucoro_awaitable = std::move(ucoro_awaitable)]() mutable -> ucoro::awaitable<void>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -162,7 +162,7 @@ namespace pscoro::asio_glue
|
||||
}
|
||||
else
|
||||
{
|
||||
auto task = [handler = std::move(handler), ucoro_awaitable = std::move(ucoro_awaitable)]() mutable -> pscoro::awaitable<void>
|
||||
auto task = [handler = std::move(handler), ucoro_awaitable = std::move(ucoro_awaitable)]() mutable -> ucoro::awaitable<void>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -181,14 +181,14 @@ namespace pscoro::asio_glue
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
auto to_asio_awaitable(pscoro::awaitable<T>&& ucoro_awaitable)
|
||||
auto to_asio_awaitable(ucoro::awaitable<T>&& ucoro_awaitable)
|
||||
{
|
||||
return boost::asio::async_initiate<decltype(boost::asio::use_awaitable), void(boost::system::error_code, T)>(
|
||||
initiate_do_invoke_ucoro_awaitable<T>{}, boost::asio::use_awaitable, std::move(ucoro_awaitable));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline auto to_asio_awaitable<void>(pscoro::awaitable<void>&& ucoro_awaitable)
|
||||
inline auto to_asio_awaitable<void>(ucoro::awaitable<void>&& ucoro_awaitable)
|
||||
{
|
||||
return boost::asio::async_initiate<decltype(boost::asio::use_awaitable), void(boost::system::error_code)>(
|
||||
initiate_do_invoke_ucoro_awaitable<void>{}, boost::asio::use_awaitable, std::move(ucoro_awaitable));
|
||||
@@ -197,10 +197,10 @@ namespace pscoro::asio_glue
|
||||
} // namespace ucoro::asio_glue
|
||||
|
||||
template<typename T>
|
||||
struct pscoro::await_transformer<boost::asio::awaitable<T>>
|
||||
struct ucoro::await_transformer<boost::asio::awaitable<T>>
|
||||
{
|
||||
static auto await_transform(boost::asio::awaitable<T>&& asio_awaitable)
|
||||
{
|
||||
return pscoro::asio_glue::asio_awaitable_awaiter<T>{std::move(asio_awaitable)};
|
||||
return ucoro::asio_glue::asio_awaitable_awaiter<T>{std::move(asio_awaitable)};
|
||||
}
|
||||
};
|
||||
|
||||
+5
-3
@@ -213,8 +213,10 @@ target_link_libraries(Core_exe PRIVATE Core_Static)
|
||||
|
||||
|
||||
|
||||
|
||||
#add_subdirectory(${core_3rd}/ucoro/ucoro ${CMAKE_BINARY_DIR}/ucoro)
|
||||
set(ucoro_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/3rd/ucoro/include/ucoro")
|
||||
if(EXISTS "${ucoro_cmake_dir}/CMakeLists.txt")
|
||||
add_subdirectory("${ucoro_cmake_dir}" "${CMAKE_BINARY_DIR}/ucoro")
|
||||
endif()
|
||||
#include(${CMAKE_CURRENT_LIST_DIR}/learn_coro_code/main.cmake)
|
||||
|
||||
|
||||
@@ -239,4 +241,4 @@ target_link_libraries(Core_exe PRIVATE Core_Static)
|
||||
# "ON"
|
||||
# "30"
|
||||
#)
|
||||
#message("2222222222222")
|
||||
#message("2222222222222")
|
||||
|
||||
Reference in New Issue
Block a user