Reduce stack consumption if unable to switch to apartment_context#1276
Merged
kennykerr merged 1 commit intomicrosoft:mastermicrosoft/cppwinrt:masterfrom Feb 16, 2023
oldnewthing:remove_workaroundoldnewthing/cppwinrt:remove_workaroundCopy head branch name to clipboard
Merged
Reduce stack consumption if unable to switch to apartment_context#1276kennykerr merged 1 commit intomicrosoft:mastermicrosoft/cppwinrt:masterfrom oldnewthing:remove_workaroundoldnewthing/cppwinrt:remove_workaroundCopy head branch name to clipboard
kennykerr merged 1 commit intomicrosoft:mastermicrosoft/cppwinrt:masterfrom
oldnewthing:remove_workaroundoldnewthing/cppwinrt:remove_workaroundCopy head branch name to clipboard
Conversation
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 `#ifdef`s 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.
kennykerr
reviewed
Feb 16, 2023
| }; | ||
|
|
||
| inline void resume_apartment_sync(com_ptr<IContextCallback> const& context, coroutine_handle<> handle, int32_t* failure) | ||
| [[nodiscard]] inline bool resume_apartment_sync(com_ptr<IContextCallback> const& context, coroutine_handle<> handle, int32_t* failure) |
kennykerr
approved these changes
Feb 16, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The old code would invoke the handle recursively. The new code returns
falsefromawait_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.