mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
sync: track upstream loom changes (#1407)
This commit is contained in:
parent
962521f449
commit
2e69f2a7fd
@ -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"] }
|
||||
|
@ -1,4 +1,4 @@
|
||||
pub(crate) mod futures {
|
||||
pub(crate) mod future {
|
||||
pub(crate) use crate::task::AtomicWaker;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::list;
|
||||
use crate::loom::{
|
||||
futures::AtomicWaker,
|
||||
future::AtomicWaker,
|
||||
sync::atomic::AtomicUsize,
|
||||
sync::{Arc, CausalCell},
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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]
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -5,6 +5,7 @@
|
||||
//! library's prelude you'll have to do so manually:
|
||||
//!
|
||||
//! ```
|
||||
//! # #![allow(warnings)]
|
||||
//! use tokio::prelude::*;
|
||||
//! ```
|
||||
//!
|
||||
|
Loading…
x
Reference in New Issue
Block a user