summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-08-07 23:24:22 -0700
committerGitHub <noreply@github.com>2019-08-07 23:24:22 -0700
commit2e69f2a7fddfe3d9940ace8ed5610cca83b75369 (patch)
tree88e73f7225ac2304280c77e39d9d56bc3c21c4ca
parent962521f449dead58eb37eb46857bc6c52ee3a8da (diff)
sync: track upstream loom changes (#1407)
-rw-r--r--tokio-sync/Cargo.toml2
-rw-r--r--tokio-sync/src/loom.rs2
-rw-r--r--tokio-sync/src/mpsc/chan.rs2
-rw-r--r--tokio-sync/src/semaphore.rs2
-rw-r--r--tokio-sync/tests/fuzz_atomic_waker.rs2
-rw-r--r--tokio-sync/tests/fuzz_mpsc.rs2
-rw-r--r--tokio-sync/tests/fuzz_oneshot.rs33
-rw-r--r--tokio-sync/tests/fuzz_semaphore.rs2
-rw-r--r--tokio/src/prelude.rs1
9 files changed, 28 insertions, 20 deletions
diff --git a/tokio-sync/Cargo.toml b/tokio-sync/Cargo.toml
index 7e593ca8..af587d95 100644
--- a/tokio-sync/Cargo.toml
+++ b/tokio-sync/Cargo.toml
@@ -35,4 +35,4 @@ env_logger = { version = "0.5", default-features = false }
pin-utils = "0.1.0-alpha.4"
tokio = { version = "*", path = "../tokio" }
tokio-test = { version = "0.2.0", path = "../tokio-test" }
-loom = { git = "https://github.com/carllerche/loom", features = ["futures"] }
+loom = { version = "0.2.0", features = ["futures"] }
diff --git a/tokio-sync/src/loom.rs b/tokio-sync/src/loom.rs
index 39755c01..564efc4f 100644
--- a/tokio-sync/src/loom.rs
+++ b/tokio-sync/src/loom.rs
@@ -1,4 +1,4 @@
-pub(crate) mod futures {
+pub(crate) mod future {
pub(crate) use crate::task::AtomicWaker;
}
diff --git a/tokio-sync/src/mpsc/chan.rs b/tokio-sync/src/mpsc/chan.rs
index 4f228f09..122537fc 100644
--- a/tokio-sync/src/mpsc/chan.rs
+++ b/tokio-sync/src/mpsc/chan.rs
@@ -1,6 +1,6 @@
use super::list;
use crate::loom::{
- futures::AtomicWaker,
+ future::AtomicWaker,
sync::atomic::AtomicUsize,
sync::{Arc, CausalCell},
};
diff --git a/tokio-sync/src/semaphore.rs b/tokio-sync/src/semaphore.rs
index 6bfe4310..a1085c6c 100644
--- a/tokio-sync/src/semaphore.rs
+++ b/tokio-sync/src/semaphore.rs
@@ -9,7 +9,7 @@
//! `Pending`. The task is woken once a permit becomes available.
use crate::loom::{
- futures::AtomicWaker,
+ future::AtomicWaker,
sync::{
atomic::{AtomicPtr, AtomicUsize},
CausalCell,
diff --git a/tokio-sync/tests/fuzz_atomic_waker.rs b/tokio-sync/tests/fuzz_atomic_waker.rs
index 526f1070..b53f90da 100644
--- a/tokio-sync/tests/fuzz_atomic_waker.rs
+++ b/tokio-sync/tests/fuzz_atomic_waker.rs
@@ -9,7 +9,7 @@ mod atomic_waker;
use crate::atomic_waker::AtomicWaker;
use futures_util::future::poll_fn;
-use loom::futures::block_on;
+use loom::future::block_on;
use loom::sync::atomic::AtomicUsize;
use loom::thread;
use std::sync::atomic::Ordering::Relaxed;
diff --git a/tokio-sync/tests/fuzz_mpsc.rs b/tokio-sync/tests/fuzz_mpsc.rs
index 0218c3af..d59f3fed 100644
--- a/tokio-sync/tests/fuzz_mpsc.rs
+++ b/tokio-sync/tests/fuzz_mpsc.rs
@@ -19,7 +19,7 @@ mod mpsc;
mod semaphore;
use futures_util::future::poll_fn;
-use loom::futures::block_on;
+use loom::future::block_on;
use loom::thread;
#[test]
diff --git a/tokio-sync/tests/fuzz_oneshot.rs b/tokio-sync/tests/fuzz_oneshot.rs
index b0191f20..31516478 100644
--- a/tokio-sync/tests/fuzz_oneshot.rs
+++ b/tokio-sync/tests/fuzz_oneshot.rs
@@ -5,11 +5,11 @@
#[allow(warnings)]
mod oneshot;
-// use futures::{self, Async, Future};
use loom;
-use loom::futures::{block_on, poll_future};
+use loom::future::block_on;
use loom::thread;
+use futures_util::future::poll_fn;
use std::task::Poll::{Pending, Ready};
#[test]
@@ -36,14 +36,19 @@ fn changing_rx_task() {
});
let rx = thread::spawn(move || {
- match poll_future(&mut rx) {
+ let ready = block_on(poll_fn(|cx| match Pin::new(&mut rx).poll(cx) {
Ready(Ok(value)) => {
- // ok
assert_eq!(1, value);
- None
+ Ready(true)
}
Ready(Err(_)) => unimplemented!(),
- Pending => Some(rx),
+ Pending => Ready(false),
+ }));
+
+ if ready {
+ None
+ } else {
+ Some(rx)
}
})
.join()
@@ -74,10 +79,11 @@ impl<'a> OnClose<'a> {
}
impl<'a> Future for OnClose<'a> {
- type Output = ();
+ type Output = bool;
- fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
- self.get_mut().tx.poll_closed(cx)
+ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<bool> {
+ let res = self.get_mut().tx.poll_closed(cx);
+ Ready(res.is_ready())
}
}
@@ -91,11 +97,12 @@ fn changing_tx_task() {
});
let tx = thread::spawn(move || {
- let t1 = poll_future(&mut OnClose::new(&mut tx));
+ let t1 = block_on(OnClose::new(&mut tx));
- match t1 {
- Ready(()) => None,
- Pending => Some(tx),
+ if t1 {
+ None
+ } else {
+ Some(tx)
}
})
.join()
diff --git a/tokio-sync/tests/fuzz_semaphore.rs b/tokio-sync/tests/fuzz_semaphore.rs
index ebc05db2..5858fd20 100644
--- a/tokio-sync/tests/fuzz_semaphore.rs
+++ b/tokio-sync/tests/fuzz_semaphore.rs
@@ -11,7 +11,7 @@ use crate::semaphore::*;
use futures_core::ready;
use futures_util::future::poll_fn;
-use loom::futures::block_on;
+use loom::future::block_on;
use loom::thread;
use std::future::Future;
use std::pin::Pin;
diff --git a/tokio/src/prelude.rs b/tokio/src/prelude.rs
index 840e7d3b..e59b1188 100644
--- a/tokio/src/prelude.rs
+++ b/tokio/src/prelude.rs
@@ -5,6 +5,7 @@
//! library's prelude you'll have to do so manually:
//!
//! ```
+//! # #![allow(warnings)]
//! use tokio::prelude::*;
//! ```
//!