From 477138d39005f45fdbc58d3bd5e5c45b6ff654ea Mon Sep 17 00:00:00 2001 From: Park DongHa Date: Sat, 4 Apr 2020 22:48:20 +0900 Subject: [PATCH] windows: disable set_or_cancel on UWP --- interface/coroutine/windows.h | 14 ++++++++++++-- modules/system/CMakeLists.txt | 4 ++-- modules/system/windows.cpp | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/interface/coroutine/windows.h b/interface/coroutine/windows.h index 07ff911e..56e5f26e 100644 --- a/interface/coroutine/windows.h +++ b/interface/coroutine/windows.h @@ -22,6 +22,8 @@ namespace coro { +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_GAMES) + /** * @brief Awaitable event type over Win32 thread pool * @ingroup Windows @@ -50,15 +52,20 @@ class set_or_cancel final { private: /** * @brief Resume the coroutine in the thread pool to wait for the event object + * @note It uses `INFINITE`, `WT_EXECUTEONLYONCE` for `RegisterWaitForSingleObject` + * * @see https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-registerwaitforsingleobject + * * @todo can we use `WT_EXECUTEINWAITTHREAD` for this type? */ void suspend(coroutine_handle) noexcept(false); public: /** - * @brief cancel the event waiting - * @return uint32_t + * @brief cancel the event waiting + * @note `ERROR_IO_PENDING` will return `NO_ERROR` because it is using `INFINITE` timeout. + * @return uint32_t `GetLastError` after `UnregisterWait` + * * @see https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-unregisterwait */ uint32_t unregister() noexcept; @@ -73,10 +80,12 @@ class set_or_cancel final { return unregister(); } }; +#endif // WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_GAMES /** * @brief Move into the win32 thread pool and continue the routine * @ingroup Windows + * * @see CreateThreadpoolWork * @see SubmitThreadpoolWork * @see CloseThreadpoolWork @@ -117,6 +126,7 @@ class continue_on_thread_pool final { /** * @brief Move into the designated thread's APC queue and continue the routine * @ingroup Windows + * * @see QueueUserAPC * @see OpenThread */ diff --git a/modules/system/CMakeLists.txt b/modules/system/CMakeLists.txt index 89e43c52..1d1f8535 100644 --- a/modules/system/CMakeLists.txt +++ b/modules/system/CMakeLists.txt @@ -5,9 +5,9 @@ string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME) if(SYSTEM_NAME MATCHES WindowsStore) set(SYSTEM_NAME windows) -elseif(ANDROID OR SYSTEM_NAME MATCHES [Aa]ndroid) +elseif(ANDROID OR SYSTEM_NAME MATCHES android) set(SYSTEM_NAME linux) -elseif(IOS OR SYSTEM_NAME MATCHES [Ii][Oo][Ss]) +elseif(IOS OR SYSTEM_NAME MATCHES ios) set(SYSTEM_NAME darwin) endif() diff --git a/modules/system/windows.cpp b/modules/system/windows.cpp index f7628c7a..d6067a4a 100644 --- a/modules/system/windows.cpp +++ b/modules/system/windows.cpp @@ -22,6 +22,7 @@ using namespace gsl; namespace coro { +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_GAMES) static_assert(is_move_assignable_v == false); static_assert(is_move_constructible_v == false); static_assert(is_copy_assignable_v == false); @@ -61,6 +62,7 @@ void set_or_cancel::suspend(coroutine_handle coro) noexcept(false) { system_category(), "RegisterWaitForSingleObject"}; } } +#endif // auto get_threads_of(DWORD pid) noexcept(false) -> enumerable { // // for current process