Skip to content

Commit

Permalink
windows: disable set_or_cancel on UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
luncliff committed Apr 4, 2020
1 parent f063e59 commit 477138d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
14 changes: 12 additions & 2 deletions interface/coroutine/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<void>) 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;
Expand All @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions modules/system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 2 additions & 0 deletions modules/system/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<set_or_cancel> == false);
static_assert(is_move_constructible_v<set_or_cancel> == false);
static_assert(is_copy_assignable_v<set_or_cancel> == false);
Expand Down Expand Up @@ -61,6 +62,7 @@ void set_or_cancel::suspend(coroutine_handle<void> coro) noexcept(false) {
system_category(), "RegisterWaitForSingleObject"};
}
}
#endif

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

0 comments on commit 477138d

Please # to comment.