microsoft / cppwinrt

C++/WinRT
MIT License
1.67k stars 239 forks source link

Reduce stack consumption if unable to switch to apartment_context #1276

Closed oldnewthing closed 1 year ago

oldnewthing commented 1 year ago

The old code would invoke the handle recursively. The new code returns false from await_suspend, allowing the calling coroutine to resume with no stack consumption. Use [[nodiscard]] to ensure I updated all callers, and to avoid future errors with new callers.

Also remove #ifdefs to work around code generation issues in MSVC versions less than 16.11. If you are on a version that old, you should stick with an older version of C++/WinRT.