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
7 changes: 7 additions & 0 deletions strings/base_coroutine_foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,14 @@ WINRT_EXPORT namespace winrt
{
auto sender_abi = *(impl::unknown_abi**)&sender;


#if defined(__cpp_lib_atomic_ref) && __cpp_lib_atomic_ref >= 201806L
void* expected = nullptr;
std::atomic_ref<void*> ref{ *reinterpret_cast<void**>(&result) };
if (ref.compare_exchange_strong(expected, static_cast<void*>(sender_abi)))
#else
if (nullptr == _InterlockedCompareExchangePointer(reinterpret_cast<void**>(&result), sender_abi, nullptr))
#endif
{
sender_abi->AddRef();
status = operation_status;
Expand Down
8 changes: 8 additions & 0 deletions test/test_cpp20_module/coroutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ TEST_CASE("module_async_cancel")
op.Cancel();
REQUIRE(op.Status() == AsyncStatus::Canceled);
}

TEST_CASE("module_async_when_any")
{
auto a = do_nothing_async();
auto b = do_nothing_async();
auto c = winrt::when_any(a, b);
c.get();
}