Skip to content

Commit 477138d

Browse files
committed
windows: disable set_or_cancel on UWP
1 parent f063e59 commit 477138d

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

interface/coroutine/windows.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
namespace coro {
2424

25+
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_GAMES)
26+
2527
/**
2628
* @brief Awaitable event type over Win32 thread pool
2729
* @ingroup Windows
@@ -50,15 +52,20 @@ class set_or_cancel final {
5052
private:
5153
/**
5254
* @brief Resume the coroutine in the thread pool to wait for the event object
55+
* @note It uses `INFINITE`, `WT_EXECUTEONLYONCE` for `RegisterWaitForSingleObject`
56+
*
5357
* @see https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-registerwaitforsingleobject
58+
*
5459
* @todo can we use `WT_EXECUTEINWAITTHREAD` for this type?
5560
*/
5661
void suspend(coroutine_handle<void>) noexcept(false);
5762

5863
public:
5964
/**
60-
* @brief cancel the event waiting
61-
* @return uint32_t
65+
* @brief cancel the event waiting
66+
* @note `ERROR_IO_PENDING` will return `NO_ERROR` because it is using `INFINITE` timeout.
67+
* @return uint32_t `GetLastError` after `UnregisterWait`
68+
*
6269
* @see https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-unregisterwait
6370
*/
6471
uint32_t unregister() noexcept;
@@ -73,10 +80,12 @@ class set_or_cancel final {
7380
return unregister();
7481
}
7582
};
83+
#endif // WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_GAMES
7684

7785
/**
7886
* @brief Move into the win32 thread pool and continue the routine
7987
* @ingroup Windows
88+
*
8089
* @see CreateThreadpoolWork
8190
* @see SubmitThreadpoolWork
8291
* @see CloseThreadpoolWork
@@ -117,6 +126,7 @@ class continue_on_thread_pool final {
117126
/**
118127
* @brief Move into the designated thread's APC queue and continue the routine
119128
* @ingroup Windows
129+
*
120130
* @see QueueUserAPC
121131
* @see OpenThread
122132
*/

modules/system/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME)
55

66
if(SYSTEM_NAME MATCHES WindowsStore)
77
set(SYSTEM_NAME windows)
8-
elseif(ANDROID OR SYSTEM_NAME MATCHES [Aa]ndroid)
8+
elseif(ANDROID OR SYSTEM_NAME MATCHES android)
99
set(SYSTEM_NAME linux)
10-
elseif(IOS OR SYSTEM_NAME MATCHES [Ii][Oo][Ss])
10+
elseif(IOS OR SYSTEM_NAME MATCHES ios)
1111
set(SYSTEM_NAME darwin)
1212
endif()
1313

modules/system/windows.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ using namespace gsl;
2222

2323
namespace coro {
2424

25+
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_GAMES)
2526
static_assert(is_move_assignable_v<set_or_cancel> == false);
2627
static_assert(is_move_constructible_v<set_or_cancel> == false);
2728
static_assert(is_copy_assignable_v<set_or_cancel> == false);
@@ -61,6 +62,7 @@ void set_or_cancel::suspend(coroutine_handle<void> coro) noexcept(false) {
6162
system_category(), "RegisterWaitForSingleObject"};
6263
}
6364
}
65+
#endif
6466

6567
// auto get_threads_of(DWORD pid) noexcept(false) -> enumerable<DWORD> {
6668
// // for current process

0 commit comments

Comments
 (0)