Remove incorrect ASSERT in ~AsyncWaitableEvent

This patch removes an incorrect ASSERT(IsComplete()) in the
destructor of AsyncWaitableEvent because when the destructor of
AsyncWaitableEvent is called, the async task attached to mFuture
may not be completed and the status of mFuture may not be 'ready'.
In fact in C++14 we can always guarantee the attached async task
is completed after the destruction of mFuture.

BUG=dawn:529

Change-Id: I2f28246beb025a0d39dd432a404c0b04aed17249
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/48900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2021-04-27 02:50:46 +00:00 committed by Commit Bot service account
parent e688e52e6c
commit c952097dc6
1 changed files with 5 additions and 3 deletions

View File

@ -25,9 +25,6 @@ namespace {
explicit AsyncWaitableEvent(std::function<void()> func) {
mFuture = std::async(std::launch::async, func);
}
virtual ~AsyncWaitableEvent() override {
ASSERT(IsComplete());
}
void Wait() override {
ASSERT(mFuture.valid());
mFuture.wait();
@ -38,6 +35,11 @@ namespace {
}
private:
// It is safe not to call Wait() in the destructor of AsyncWaitableEvent because since
// C++14 the destructor of std::future will always be blocked until its state becomes
// std::future_status::ready when it was created by a call of std::async and it is the
// last reference to the shared state.
// See https://en.cppreference.com/w/cpp/thread/future/~future for more details.
std::future<void> mFuture;
};