]>
git.proxmox.com Git - rustc.git/blob - vendor/tokio/src/sync/tests/loom_atomic_waker.rs
1 use crate::sync
::task
::AtomicWaker
;
3 use futures
::future
::poll_fn
;
4 use loom
::future
::block_on
;
5 use loom
::sync
::atomic
::AtomicUsize
;
7 use std
::sync
::atomic
::Ordering
::Relaxed
;
9 use std
::task
::Poll
::{Pending, Ready}
;
17 fn basic_notification() {
18 const NUM_NOTIFY
: usize = 2;
21 let chan
= Arc
::new(Chan
{
22 num
: AtomicUsize
::new(0),
23 task
: AtomicWaker
::new(),
26 for _
in 0..NUM_NOTIFY
{
27 let chan
= chan
.clone();
29 thread
::spawn(move || {
30 chan
.num
.fetch_add(1, Relaxed
);
35 block_on(poll_fn(move |cx
| {
36 chan
.task
.register_by_ref(cx
.waker());
38 if NUM_NOTIFY
== chan
.num
.load(Relaxed
) {