Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
compiler: [MSVC, clang-cl]
arch: [x86, x64, arm64]
config: [Debug, Release]
test_exe: [test, test_cpp20, test_cpp20_no_sourcelocation, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
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]
exclude:
- arch: arm64
config: Debug
Expand Down
4 changes: 4 additions & 0 deletions .pipelines/jobs/OneBranchTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
TestExe: 'test'
TestProject: 'test'
BuildPlatform: 'x86'
test_nocoro.x86:
TestExe: 'test_nocoro'
TestProject: 'test_nocoro'
BuildPlatform: 'x86'
test_cpp20.x86:
TestExe: 'test_cpp20'
TestProject: 'test_cpp20'
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.Props
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<PropertyGroup Condition="'$(Clang)'=='1'">
<PlatformToolset>ClangCL</PlatformToolset>
<!-- The experimental coroutines aren't supported under Clang -->
<!-- No coroutines in C++17 mode under Clang -->
<CppWinRTLanguageStandard>20</CppWinRTLanguageStandard>
<!-- Disable vcpkg autolink because it's not compatible with lld-link -->
<VcpkgAutoLink>false</VcpkgAutoLink>
Expand Down Expand Up @@ -60,7 +60,7 @@
<PreprocessorDefinitions Condition="'$(TestsUseAnsiColor)'=='1'">CATCH_CONFIG_COLOUR_ANSI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions>/bigobj</AdditionalOptions>
<AdditionalOptions Condition="'$(CppWinRTLanguageStandard)'==''">/await %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(CppWinRTLanguageStandard)'=='' And '$(CppWinRTUseCoroutines)'==''">/await:strict %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Clang)'=='1'">-Wno-unused-command-line-argument -fno-delayed-template-parsing -mcx16</AdditionalOptions>
</ClCompile>
<Link>
Expand Down
1 change: 1 addition & 0 deletions build_test_all.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platfor
call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% test\nuget\NugetTest.sln

call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_nocoro
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_cpp20
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_cpp20_no_sourcelocation
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_fast
Expand Down
18 changes: 18 additions & 0 deletions cppwinrt.sln
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_cpp20_no_sourcelocatio
{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_nocoro", "test\test_nocoro\test_nocoro.vcxproj", "{9E392830-805A-4AAF-932D-C493143EFACA}"
ProjectSection(ProjectDependencies) = postProject
{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D15C8430-A7CD-4616-BD84-243B26A9F1C2}"
ProjectSection(SolutionItems) = preProject
build_nuget.cmd = build_nuget.cmd
Expand Down Expand Up @@ -394,6 +399,18 @@ Global
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374}.Release|x64.Build.0 = Release|x64
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374}.Release|x86.ActiveCfg = Release|Win32
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374}.Release|x86.Build.0 = Release|Win32
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|ARM64.ActiveCfg = Debug|ARM64
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|ARM64.Build.0 = Debug|ARM64
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x64.ActiveCfg = Debug|x64
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x64.Build.0 = Debug|x64
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x86.ActiveCfg = Debug|Win32
{9E392830-805A-4AAF-932D-C493143EFACA}.Debug|x86.Build.0 = Debug|Win32
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|ARM64.ActiveCfg = Release|ARM64
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|ARM64.Build.0 = Release|ARM64
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x64.ActiveCfg = Release|x64
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x64.Build.0 = Release|x64
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x86.ActiveCfg = Release|Win32
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -417,6 +434,7 @@ Global
{08C40663-B6A3-481E-8755-AE32BAD99501} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
{5FF6CD6C-515A-4D55-97B6-62AD9BCB77EA} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
{9E392830-805A-4AAF-932D-C493143EFACA} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2783B8FD-EA3B-4D6B-9F81-662D289E02AA}
Expand Down
4 changes: 0 additions & 4 deletions cppwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3477,10 +3477,6 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
{
w.write(strings::base_coroutine_system);
}
else if (namespace_name == "Microsoft.System")
{
w.write(strings::base_coroutine_system_winui);
}
else if (namespace_name == "Windows.UI.Core")
{
w.write(strings::base_coroutine_ui_core);
Expand Down
6 changes: 3 additions & 3 deletions nuget/CppWinrtRules.Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
Description="Enables or disables the default for copying binaries to the output folder to be false"
Category="General" />

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

</Rule>
2 changes: 1 addition & 1 deletion nuget/Microsoft.Windows.CppWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ $(XamlMetaDataProviderPch)
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
<AdditionalOptions Condition="'%(ClCompile.LanguageStandard)' == 'stdcpp17' And '$(CppWinRTEnableLegacyCoroutines)' != 'false'">%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalOptions Condition="'%(ClCompile.LanguageStandard)' == 'stdcpp17' And '$(CppWinRTEnableCpp17Coroutines)' != 'false'">%(AdditionalOptions) /await:strict</AdditionalOptions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(GeneratedFilesDir)</AdditionalIncludeDirectories>
</ClCompile>
<Midl Condition="'$(CppWinRTModernIDL)' != 'false'">
Expand Down
1 change: 1 addition & 0 deletions run_tests.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if "%target_platform%"=="" set target_platform=x64
if "%target_configuration%"=="" set target_configuration=Debug

call :run_test test
call :run_test test_nocoro
call :run_test test_cpp20
call :run_test test_cpp20_no_sourcelocation
call :run_test test_fast
Expand Down
28 changes: 11 additions & 17 deletions strings/base_coroutine_foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ namespace winrt::impl
return async.GetResults();
}

#ifdef WINRT_IMPL_COROUTINES
struct ignore_apartment_context {};

template<bool preserve_context, typename Awaiter>
struct disconnect_aware_handler : private std::conditional_t<preserve_context, resume_apartment_context, ignore_apartment_context>
{
disconnect_aware_handler(Awaiter* awaiter, coroutine_handle<> handle) noexcept
disconnect_aware_handler(Awaiter* awaiter, std::coroutine_handle<> handle) noexcept
: m_awaiter(awaiter), m_handle(handle) { }

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

private:
movable_primitive<Awaiter*> m_awaiter;
movable_primitive<coroutine_handle<>, nullptr> m_handle;
movable_primitive<std::coroutine_handle<>, nullptr> m_handle;

void Complete()
{
Expand All @@ -149,7 +150,6 @@ namespace winrt::impl
}
};

#ifdef WINRT_IMPL_COROUTINES
template <typename Async, bool preserve_context = true>
struct await_adapter : cancellable_awaiter<await_adapter<Async, preserve_context>>
{
Expand All @@ -175,7 +175,7 @@ namespace winrt::impl
}

template <typename T>
bool await_suspend(coroutine_handle<T> handle)
bool await_suspend(std::coroutine_handle<T> handle)
{
this->set_cancellable_promise_from_handle(handle);
return register_completed_callback(handle);
Expand All @@ -189,7 +189,7 @@ namespace winrt::impl
}

private:
bool register_completed_callback(coroutine_handle<> handle)
bool register_completed_callback(std::coroutine_handle<> handle)
{
if constexpr (!preserve_context)
{
Expand Down Expand Up @@ -294,7 +294,6 @@ WINRT_EXPORT namespace winrt::Windows::Foundation
return{ async };
}
}
#endif

WINRT_EXPORT namespace winrt
{
Expand Down Expand Up @@ -327,7 +326,7 @@ namespace winrt::impl
return true;
}

void await_suspend(coroutine_handle<>) const noexcept
void await_suspend(std::coroutine_handle<>) const noexcept
{
}

Expand Down Expand Up @@ -373,7 +372,7 @@ namespace winrt::impl
return true;
}

void await_suspend(coroutine_handle<>) const noexcept
void await_suspend(std::coroutine_handle<>) const noexcept
{
}

Expand Down Expand Up @@ -411,7 +410,7 @@ namespace winrt::impl
if (remaining == 0)
{
std::atomic_thread_fence(std::memory_order_acquire);
coroutine_handle<Derived>::from_promise(*static_cast<Derived*>(this)).destroy();
std::coroutine_handle<Derived>::from_promise(*static_cast<Derived*>(this)).destroy();
}

return remaining;
Expand Down Expand Up @@ -577,7 +576,7 @@ namespace winrt::impl
}
}

suspend_never initial_suspend() const noexcept
std::suspend_never initial_suspend() const noexcept
{
return{};
}
Expand All @@ -595,7 +594,7 @@ namespace winrt::impl
{
}

bool await_suspend(coroutine_handle<>) const noexcept
bool await_suspend(std::coroutine_handle<>) const noexcept
{
promise->set_completed();
uint32_t const remaining = promise->subtract_reference();
Expand Down Expand Up @@ -705,11 +704,7 @@ namespace winrt::impl
};
}

#ifdef __cpp_lib_coroutine
namespace std
#else
namespace std::experimental
#endif
{
template <typename... Args>
struct coroutine_traits<winrt::Windows::Foundation::IAsyncAction, Args...>
Expand Down Expand Up @@ -844,7 +839,6 @@ namespace std::experimental

WINRT_EXPORT namespace winrt
{
#ifdef WINRT_IMPL_COROUTINES
template <typename... T>
Windows::Foundation::IAsyncAction when_all(T... async)
{
Expand Down Expand Up @@ -890,5 +884,5 @@ WINRT_EXPORT namespace winrt
impl::check_status_canceled(shared->status);
co_return shared->result.GetResults();
}
#endif
}
#endif
6 changes: 3 additions & 3 deletions strings/base_coroutine_system.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#ifdef WINRT_IMPL_COROUTINES
WINRT_EXPORT namespace winrt
{
[[nodiscard]] inline auto resume_foreground(
Expand All @@ -23,7 +24,7 @@ WINRT_EXPORT namespace winrt
return m_queued;
}

bool await_suspend(impl::coroutine_handle<> handle)
bool await_suspend(std::coroutine_handle<> handle)
{
return m_dispatcher.TryEnqueue(m_priority, [handle, this]
{
Expand All @@ -41,10 +42,9 @@ WINRT_EXPORT namespace winrt
return awaitable{ dispatcher, priority };
};

#ifdef WINRT_IMPL_COROUTINES
inline auto operator co_await(Windows::System::DispatcherQueue const& dispatcher)
{
return resume_foreground(dispatcher);
}
#endif
}
#endif
50 changes: 0 additions & 50 deletions strings/base_coroutine_system_winui.h

This file was deleted.

Loading