Skip to content

Commit

Permalink
Simply when_all implementation and test (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing authored May 31, 2020
1 parent d610942 commit d6a0412
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion strings/base_coroutine_foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ WINRT_EXPORT namespace winrt
template <typename... T>
Windows::Foundation::IAsyncAction when_all(T... async)
{
((co_await async, void()), ...);
(void(co_await async), ...);
co_return;
}

Expand Down
7 changes: 5 additions & 2 deletions test/test/when.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ using namespace concurrency;
using namespace winrt;
using namespace Windows::Foundation;

struct CommaStruct
struct CommaStruct : std::experimental::suspend_never
{
// If the comma operator is invoked, we will get a build failure.
CommaStruct operator,(CommaStruct) = delete;

// Awaiting the object just returns itself.
auto await_resume() const { return *this; }
};

task<void> ppl(bool& done)
Expand Down Expand Up @@ -56,7 +59,7 @@ TEST_CASE("when")
when_all().get();

// Verify edge case of overloaded comma operator (shame on you).
when_all(create_task([] { return CommaStruct{}; }), create_task([] { return CommaStruct{}; })).get();
when_all(CommaStruct{}, CommaStruct{}).get();
{
handle first_event{ check_pointer(CreateEventW(nullptr, true, false, nullptr)) };
handle second_event{ check_pointer(CreateEventW(nullptr, true, false, nullptr)) };
Expand Down

0 comments on commit d6a0412

Please sign in to comment.