Skip to content

Commit

Permalink
Merge pull request #899 from aelovikov-intel/fix-race
Browse files Browse the repository at this point in the history
Fix race condition in event test
  • Loading branch information
bader authored Jun 13, 2024
2 parents c53889c + 9e5015d commit 93ffc68
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 93ffc68

Please sign in to comment.