Skip to content

Commit d9b0b09

Browse files
committed
Remove experimental coroutines support
Replace CppWinRTEnableLegacyCoroutines with CppWinRTEnableCpp17Coroutines Remove base_coroutine_system_winui.h, hasn't worked since PR 0.8 Support and test building with no coroutines Remove implementation selection machinery
1 parent dcaa98c commit d9b0b09

30 files changed

+494
-206
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
compiler: [MSVC, clang-cl]
9393
arch: [x86, x64, arm64]
9494
config: [Debug, Release]
95-
test_exe: [test, test_cpp20, test_cpp20_no_sourcelocation, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
95+
test_exe: [test, test_nocoro, test_cpp20, test_cpp20_no_sourcelocation, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
9696
exclude:
9797
- arch: arm64
9898
config: Debug

.pipelines/jobs/OneBranchTest.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
TestExe: 'test'
1818
TestProject: 'test'
1919
BuildPlatform: 'x86'
20+
test_nocoro.x86:
21+
TestExe: 'test_nocoro'
22+
TestProject: 'test_nocoro'
23+
BuildPlatform: 'x86'
2024
test_cpp20.x86:
2125
TestExe: 'test_cpp20'
2226
TestProject: 'test_cpp20'

Directory.Build.Props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<PropertyGroup Condition="'$(Clang)'=='1'">
3232
<PlatformToolset>ClangCL</PlatformToolset>
33-
<!-- The experimental coroutines aren't supported under Clang -->
33+
<!-- No coroutines in C++17 mode under Clang -->
3434
<CppWinRTLanguageStandard>20</CppWinRTLanguageStandard>
3535
<!-- Disable vcpkg autolink because it's not compatible with lld-link -->
3636
<VcpkgAutoLink>false</VcpkgAutoLink>
@@ -60,7 +60,7 @@
6060
<PreprocessorDefinitions Condition="'$(TestsUseAnsiColor)'=='1'">CATCH_CONFIG_COLOUR_ANSI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
6161
<MultiProcessorCompilation>true</MultiProcessorCompilation>
6262
<AdditionalOptions>/bigobj</AdditionalOptions>
63-
<AdditionalOptions Condition="'$(CppWinRTLanguageStandard)'==''">/await %(AdditionalOptions)</AdditionalOptions>
63+
<AdditionalOptions Condition="'$(CppWinRTLanguageStandard)'=='' And '$(CppWinRTUseCoroutines)'==''">/await:strict %(AdditionalOptions)</AdditionalOptions>
6464
<AdditionalOptions Condition="'$(Clang)'=='1'">-Wno-unused-command-line-argument -fno-delayed-template-parsing -mcx16</AdditionalOptions>
6565
</ClCompile>
6666
<Link>

build_test_all.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platfor
2828
call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% test\nuget\NugetTest.sln
2929

3030
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test
31+
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_nocoro
3132
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_cpp20
3233
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_cpp20_no_sourcelocation
3334
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_fast

cppwinrt.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_cpp20_no_sourcelocatio
119119
{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}
120120
EndProjectSection
121121
EndProject
122+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_nocoro", "test\test_nocoro\test_nocoro.vcxproj", "{9E392830-805A-4AAF-932D-C493143EFACA}"
123+
ProjectSection(ProjectDependencies) = postProject
124+
{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}
125+
EndProjectSection
126+
EndProject
122127
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D15C8430-A7CD-4616-BD84-243B26A9F1C2}"
123128
ProjectSection(SolutionItems) = preProject
124129
build_nuget.cmd = build_nuget.cmd
@@ -394,6 +399,18 @@ Global
394399
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374}.Release|x64.Build.0 = Release|x64
395400
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374}.Release|x86.ActiveCfg = Release|Win32
396401
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374}.Release|x86.Build.0 = Release|Win32
402+
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|ARM64.ActiveCfg = Debug|ARM64
403+
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|ARM64.Build.0 = Debug|ARM64
404+
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x64.ActiveCfg = Debug|x64
405+
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x64.Build.0 = Debug|x64
406+
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x86.ActiveCfg = Debug|Win32
407+
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x86.Build.0 = Debug|Win32
408+
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|ARM64.ActiveCfg = Release|ARM64
409+
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|ARM64.Build.0 = Release|ARM64
410+
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x64.ActiveCfg = Release|x64
411+
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x64.Build.0 = Release|x64
412+
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x86.ActiveCfg = Release|Win32
413+
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x86.Build.0 = Release|Win32
397414
EndGlobalSection
398415
GlobalSection(SolutionProperties) = preSolution
399416
HideSolutionNode = FALSE
@@ -417,6 +434,7 @@ Global
417434
{08C40663-B6A3-481E-8755-AE32BAD99501} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
418435
{5FF6CD6C-515A-4D55-97B6-62AD9BCB77EA} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
419436
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
437+
{9E392830-805A-4AAF-932D-C493143EFACA} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
420438
EndGlobalSection
421439
GlobalSection(ExtensibilityGlobals) = postSolution
422440
SolutionGuid = {2783B8FD-EA3B-4D6B-9F81-662D289E02AA}

cppwinrt/code_writers.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,10 +3477,6 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
34773477
{
34783478
w.write(strings::base_coroutine_system);
34793479
}
3480-
else if (namespace_name == "Microsoft.System")
3481-
{
3482-
w.write(strings::base_coroutine_system_winui);
3483-
}
34843480
else if (namespace_name == "Windows.UI.Core")
34853481
{
34863482
w.write(strings::base_coroutine_ui_core);

nuget/CppWinrtRules.Project.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@
8181
Description="Enables or disables the default for copying binaries to the output folder to be false"
8282
Category="General" />
8383

84-
<BoolProperty Name="CppWinRTEnableLegacyCoroutines"
85-
DisplayName="Enable legacy coroutines (C++17)"
86-
Description="Enables the /await compiler option (disable this if you want to pass this yourself)"
84+
<BoolProperty Name="CppWinRTEnableCpp17Coroutines"
85+
DisplayName="Enable C++17 coroutines"
86+
Description="Enables the /await:strict compiler option"
8787
Category="General" />
8888

8989
</Rule>

nuget/Microsoft.Windows.CppWinRT.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ $(XamlMetaDataProviderPch)
882882
<ItemDefinitionGroup>
883883
<ClCompile>
884884
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
885-
<AdditionalOptions Condition="'%(ClCompile.LanguageStandard)' == 'stdcpp17' And '$(CppWinRTEnableLegacyCoroutines)' != 'false'">%(AdditionalOptions) /await</AdditionalOptions>
885+
<AdditionalOptions Condition="'%(ClCompile.LanguageStandard)' == 'stdcpp17' And '$(CppWinRTEnableCpp17Coroutines)' != 'false'">%(AdditionalOptions) /await:strict</AdditionalOptions>
886886
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(GeneratedFilesDir)</AdditionalIncludeDirectories>
887887
</ClCompile>
888888
<Midl Condition="'$(CppWinRTModernIDL)' != 'false'">

run_tests.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if "%target_platform%"=="" set target_platform=x64
99
if "%target_configuration%"=="" set target_configuration=Debug
1010

1111
call :run_test test
12+
call :run_test test_nocoro
1213
call :run_test test_cpp20
1314
call :run_test test_cpp20_no_sourcelocation
1415
call :run_test test_fast

strings/base_coroutine_foundation.h

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,13 @@ namespace winrt::impl
9999
return async.GetResults();
100100
}
101101

102+
#ifdef WINRT_IMPL_COROUTINES
102103
struct ignore_apartment_context {};
103104

104105
template<bool preserve_context, typename Awaiter>
105106
struct disconnect_aware_handler : private std::conditional_t<preserve_context, resume_apartment_context, ignore_apartment_context>
106107
{
107-
disconnect_aware_handler(Awaiter* awaiter, coroutine_handle<> handle) noexcept
108+
disconnect_aware_handler(Awaiter* awaiter, std::coroutine_handle<> handle) noexcept
108109
: m_awaiter(awaiter), m_handle(handle) { }
109110

110111
disconnect_aware_handler(disconnect_aware_handler&& other) = default;
@@ -123,7 +124,7 @@ namespace winrt::impl
123124

124125
private:
125126
movable_primitive<Awaiter*> m_awaiter;
126-
movable_primitive<coroutine_handle<>, nullptr> m_handle;
127+
movable_primitive<std::coroutine_handle<>, nullptr> m_handle;
127128

128129
void Complete()
129130
{
@@ -149,7 +150,6 @@ namespace winrt::impl
149150
}
150151
};
151152

152-
#ifdef WINRT_IMPL_COROUTINES
153153
template <typename Async, bool preserve_context = true>
154154
struct await_adapter : cancellable_awaiter<await_adapter<Async, preserve_context>>
155155
{
@@ -175,7 +175,7 @@ namespace winrt::impl
175175
}
176176

177177
template <typename T>
178-
bool await_suspend(coroutine_handle<T> handle)
178+
bool await_suspend(std::coroutine_handle<T> handle)
179179
{
180180
this->set_cancellable_promise_from_handle(handle);
181181
return register_completed_callback(handle);
@@ -189,7 +189,7 @@ namespace winrt::impl
189189
}
190190

191191
private:
192-
bool register_completed_callback(coroutine_handle<> handle)
192+
bool register_completed_callback(std::coroutine_handle<> handle)
193193
{
194194
if constexpr (!preserve_context)
195195
{
@@ -294,7 +294,6 @@ WINRT_EXPORT namespace winrt::Windows::Foundation
294294
return{ async };
295295
}
296296
}
297-
#endif
298297

299298
WINRT_EXPORT namespace winrt
300299
{
@@ -327,7 +326,7 @@ namespace winrt::impl
327326
return true;
328327
}
329328

330-
void await_suspend(coroutine_handle<>) const noexcept
329+
void await_suspend(std::coroutine_handle<>) const noexcept
331330
{
332331
}
333332

@@ -373,7 +372,7 @@ namespace winrt::impl
373372
return true;
374373
}
375374

376-
void await_suspend(coroutine_handle<>) const noexcept
375+
void await_suspend(std::coroutine_handle<>) const noexcept
377376
{
378377
}
379378

@@ -411,7 +410,7 @@ namespace winrt::impl
411410
if (remaining == 0)
412411
{
413412
std::atomic_thread_fence(std::memory_order_acquire);
414-
coroutine_handle<Derived>::from_promise(*static_cast<Derived*>(this)).destroy();
413+
std::coroutine_handle<Derived>::from_promise(*static_cast<Derived*>(this)).destroy();
415414
}
416415

417416
return remaining;
@@ -577,7 +576,7 @@ namespace winrt::impl
577576
}
578577
}
579578

580-
suspend_never initial_suspend() const noexcept
579+
std::suspend_never initial_suspend() const noexcept
581580
{
582581
return{};
583582
}
@@ -595,7 +594,7 @@ namespace winrt::impl
595594
{
596595
}
597596

598-
bool await_suspend(coroutine_handle<>) const noexcept
597+
bool await_suspend(std::coroutine_handle<>) const noexcept
599598
{
600599
promise->set_completed();
601600
uint32_t const remaining = promise->subtract_reference();
@@ -705,11 +704,7 @@ namespace winrt::impl
705704
};
706705
}
707706

708-
#ifdef __cpp_lib_coroutine
709707
namespace std
710-
#else
711-
namespace std::experimental
712-
#endif
713708
{
714709
template <typename... Args>
715710
struct coroutine_traits<winrt::Windows::Foundation::IAsyncAction, Args...>
@@ -844,7 +839,6 @@ namespace std::experimental
844839

845840
WINRT_EXPORT namespace winrt
846841
{
847-
#ifdef WINRT_IMPL_COROUTINES
848842
template <typename... T>
849843
Windows::Foundation::IAsyncAction when_all(T... async)
850844
{
@@ -890,5 +884,5 @@ WINRT_EXPORT namespace winrt
890884
impl::check_status_canceled(shared->status);
891885
co_return shared->result.GetResults();
892886
}
893-
#endif
894887
}
888+
#endif

0 commit comments

Comments
 (0)