@@ -27,46 +27,12 @@ namespace
2727 }
2828#endif
2929
30- // Simple awaiter that (inefficiently) resumes from inside a function nested in
31- // await_suspend, for the purpose of measuring how much stack it consumes.
32- // This is the best we can do with MSVC prerelease coroutines prior to 16.11.
33- // This simulates the behavior of await_adapter.
34- struct resume_sync_from_await_suspend
35- {
36- bool await_ready () { return false ; }
37- template <typename T>
38- void await_suspend (winrt::impl::coroutine_handle<T> h) { resume_inner (h); }
39- void await_resume () { }
40-
41- private:
42- void resume_inner (winrt::impl::coroutine_handle<> h) { h (); }
43- };
44-
4530 IAsyncAction SyncCompletion ()
4631 {
4732 uintptr_t initial = approximate_stack_pointer ();
48- co_await resume_sync_from_await_suspend ();
49- uintptr_t sync_usage = initial - approximate_stack_pointer ();
50-
51- initial = approximate_stack_pointer ();
5233 co_await AlreadyCompleted ();
5334 uintptr_t consumed = initial - approximate_stack_pointer ();
54- #ifdef _RESUMABLE_FUNCTIONS_SUPPORTED
55- // This branch is taken only for MSVC prerelease coroutines.
56- //
57- // MSVC prerelease coroutines prior to 16.11 do not implement "bool await_suspend" reliably,
58- // so we can't use it impl::await_adapter. We must resume inline inside await_suspend,
59- // so there is a small amount of stack usage. (Pre-16.11 and post-16.11 prerelease coroutines
60- // are interoperable, so we cannot change behavior based on which compiler we are using,
61- // because that would introduce ODR violations. Our first opportunity to change behavior
62- // is the ABI breaking change with MSVC standard-conforming coroutines.)
63- REQUIRE (consumed <= sync_usage);
64- #else
65- (void )sync_usage;
66- // MSVC standard-conforming coroutines (as well as gcc and clang coroutines)
67- // support "bool await_suspend" just fine.
6835 REQUIRE (consumed == 0 );
69- #endif
7036 }
7137
7238 // co_await the same apartment context and confirm that stack does not grow.
@@ -77,28 +43,9 @@ namespace
7743 winrt::apartment_context same_context;
7844
7945 uintptr_t initial = approximate_stack_pointer ();
80- co_await resume_sync_from_await_suspend ();
81- uintptr_t sync_usage = initial - approximate_stack_pointer ();
82-
83- initial = approximate_stack_pointer ();
8446 co_await same_context;
8547 uintptr_t consumed = initial - approximate_stack_pointer ();
86-
87- #ifdef _RESUMABLE_FUNCTIONS_SUPPORTED
88- // This branch is taken only for MSVC prerelease coroutines.
89- //
90- // MSVC prerelease coroutines prior to 16.11 do not implement "bool await_suspend" reliably,
91- // so we can't use it impl::apartment_awaiter. We must resume inline inside await_suspend,
92- // so there is a small amount of stack usage. (Pre-16.11 and post-16.11 prerelease coroutines
93- // are interoperable, so we cannot change behavior based on which compiler we are using,
94- // because that would introduce ODR violations. Our first opportunity to change behavior
95- // is the ABI breaking change with MSVC standard-conforming coroutines.)
96- REQUIRE (consumed <= sync_usage);
97- #else
98- // MSVC standard-conforming coroutines (as well as gcc and clang coroutines)
99- // support "bool await_suspend" just fine.
10048 REQUIRE (consumed == 0 );
101- #endif
10249 }
10350}
10451TEST_CASE (" await_completed_await" )
0 commit comments