Skip to content

Commit

Permalink
simplify code by using future
Browse files Browse the repository at this point in the history
  • Loading branch information
TApplencourt committed Jan 30, 2025
1 parent 3303945 commit c2f6ba0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tests/extension/khr_queue_empty_query/queue_empty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "../../common/common.h"
#include <atomic>
#include <future>
#include <iostream>

namespace queue_empty_query::tests {
Expand All @@ -41,22 +42,17 @@ TEST_CASE("queue are empty by default", "[khr_queue_empty_query]") {
TEST_CASE("queue are not empty when a command have been enqueed",
"[khr_queue_empty_query]") {
sycl::queue q{};
std::atomic_bool start = false;
std::promise<void> promise;

auto e1 = q.submit([&](sycl::handler& cgh) {
cgh.host_task([&]() {
// To avoid the loop being optimized away
int iter = 0;
while (start != true) {
iter++;
}
std::cout << iter << std::endl;
promise.get_future().wait();
});
});
CHECK(!q.khr_empty());
auto e2 = q.single_task(e1, [=] {});
CHECK(!q.khr_empty());
start = true;
promise.set_value();
e2.wait();
CHECK(q.khr_empty());
}
Expand Down

0 comments on commit c2f6ba0

Please sign in to comment.