Skip to content

Commit 6752a1d

Browse files
committed
Fix huge bugs of CountDownLatch(future version)
1 parent c5933b2 commit 6752a1d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sync.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ impl Future for CountDownLatch {
298298
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
299299
let &(ref remaining, _) = &*self.pair.clone();
300300
if *remaining.lock().unwrap() > 0 {
301-
Poll::Ready(())
302-
} else {
303301
self.waker.lock().unwrap().replace(cx.waker().clone());
304302
Poll::Pending
303+
} else {
304+
Poll::Ready(())
305305
}
306306
}
307307
}
@@ -477,7 +477,7 @@ async fn test_sync_future() {
477477
let latch2 = latch.clone();
478478

479479
let _ = pub1.subscribe(Arc::new(Mutex::new(SubscriptionFunc::new(move |_| {
480-
println!("{:?}", "SS");
480+
println!("{:?}", "test_sync_future");
481481
latch2.countdown();
482482
}))));
483483

0 commit comments

Comments
 (0)