Skip to content

Commit 33128d9

Browse files
Simplify redundant code
1 parent c8d1aea commit 33128d9

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

oneapi-rs/src/event.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@ impl Future for EventFuture {
5959
this.shared.waker.register(cx.waker());
6060
unsafe { ffi::register_callback(&mut queue.0, &this.event.0, this.shared) };
6161
this.queue.replace(queue);
62-
63-
// Check the event again to avoid a race condition
64-
// https://docs.rs/futures/latest/futures/task/struct.AtomicWaker.html#examples
65-
if this.shared.done.load(Relaxed) {
66-
Poll::Ready(())
67-
}
68-
else {
69-
Poll::Pending
70-
}
7162
}
7263
else {
7364
// Quick check before registering to avoid wasting time
@@ -77,16 +68,15 @@ impl Future for EventFuture {
7768

7869
// Register the waker if result isn't ready. This is a slow atomic operation
7970
this.shared.waker.register(cx.waker());
71+
}
8072

81-
// Check the event again to avoid a race condition
82-
// https://docs.rs/futures/latest/futures/task/struct.AtomicWaker.html#examples
83-
if this.shared.done.load(Relaxed) {
84-
Poll::Ready(())
85-
}
86-
else {
87-
Poll::Pending
88-
}
89-
73+
// Check the event again to avoid a race condition
74+
// https://docs.rs/futures/latest/futures/task/struct.AtomicWaker.html#examples
75+
if this.shared.done.load(Relaxed) {
76+
Poll::Ready(())
77+
}
78+
else {
79+
Poll::Pending
9080
}
9181
}
9282
}

0 commit comments

Comments
 (0)