Skip to content

Commit

Permalink
Fix race condition in event test
Browse files Browse the repository at this point in the history
  • Loading branch information
aelovikov-intel committed Jun 4, 2024
1 parent 689839c commit 9e5015d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/event/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ class delayed_host_event : public resolvable_host_event {
: resolvable_host_event() {
future = std::async(std::launch::async, [this, delay] {
std::this_thread::sleep_for(delay);
resolve();
// For the purpose of the tests it's important that `resolved` will be
// true whenever SYCL event is completed. As such, we have to set this
// flag before actually resolving the `future` because otherwise the
// current thread can go to sleep before the flag is set and the checks
// would be failing.
resolved = true;
resolve();
});
}

Expand Down

0 comments on commit 9e5015d

Please sign in to comment.