mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
time: rename tokio::timer
-> tokio::time
(#1745)
This commit is contained in:
parent
4dbe6af0a1
commit
7e35922a1d
@ -1,10 +1,9 @@
|
||||
//! A mocked clock for use with `tokio::timer` based futures.
|
||||
//! A mocked clock for use with `tokio::time` based futures.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! use tokio::clock;
|
||||
//! use tokio::timer::delay;
|
||||
//! use tokio::time::{clock, delay};
|
||||
//! use tokio_test::{assert_ready, assert_pending, task};
|
||||
//!
|
||||
//! use std::time::Duration;
|
||||
@ -23,8 +22,8 @@
|
||||
//! ```
|
||||
|
||||
use tokio::runtime::{Park, Unpark};
|
||||
use tokio::timer::clock::{Clock, Now};
|
||||
use tokio::timer::Timer;
|
||||
use tokio::time::clock::{Clock, Now};
|
||||
use tokio::time::Timer;
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
@ -125,13 +124,13 @@ impl MockClock {
|
||||
where
|
||||
F: FnOnce(&mut Handle) -> R,
|
||||
{
|
||||
tokio::timer::clock::with_default(&self.clock, || {
|
||||
tokio::time::clock::with_default(&self.clock, || {
|
||||
let park = self.time.mock_park();
|
||||
let timer = Timer::new(park);
|
||||
let handle = timer.handle();
|
||||
let time = self.time.clone();
|
||||
|
||||
let _timer = tokio::timer::set_default(&handle);
|
||||
let _timer = tokio::time::set_default(&handle);
|
||||
let mut handle = Handle::new(timer, time);
|
||||
f(&mut handle)
|
||||
// lazy(|| Ok::<_, ()>(f(&mut handle))).wait().unwrap()
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::timer::{clock, timer, Delay};
|
||||
use tokio::time::{clock, timer, Delay};
|
||||
|
||||
use bytes::Buf;
|
||||
use futures_core::ready;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::timer::delay;
|
||||
use tokio::time::delay;
|
||||
use tokio_test::block_on;
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::timer::delay;
|
||||
use tokio::time::delay;
|
||||
use tokio_test::clock::MockClock;
|
||||
use tokio_test::task;
|
||||
use tokio_test::{assert_pending, assert_ready};
|
||||
|
@ -33,7 +33,7 @@ default = [
|
||||
"rt-full",
|
||||
"signal",
|
||||
"sync",
|
||||
"timer",
|
||||
"time",
|
||||
]
|
||||
|
||||
executor-core = []
|
||||
@ -47,7 +47,7 @@ net-full = ["tcp", "udp", "uds"]
|
||||
net-driver = ["io-traits", "mio", "blocking", "lazy_static"]
|
||||
rt-current-thread = [
|
||||
"executor-core",
|
||||
"timer",
|
||||
"time",
|
||||
"sync",
|
||||
"net-driver",
|
||||
]
|
||||
@ -58,7 +58,7 @@ rt-full = [
|
||||
"net-full",
|
||||
"rt-current-thread",
|
||||
"sync",
|
||||
"timer",
|
||||
"time",
|
||||
]
|
||||
signal = [
|
||||
"lazy_static",
|
||||
@ -71,7 +71,7 @@ signal = [
|
||||
]
|
||||
sync = ["fnv"]
|
||||
tcp = ["io", "net-driver"]
|
||||
timer = ["executor-core", "sync", "slab"]
|
||||
time = ["executor-core", "sync", "slab"]
|
||||
udp = ["io", "net-driver"]
|
||||
uds = ["io", "net-driver", "mio-uds", "libc"]
|
||||
process = [
|
||||
|
@ -1,14 +0,0 @@
|
||||
//! A configurable source of time.
|
||||
//!
|
||||
//! This module provides the [`now`][n] function, which returns an `Instant`
|
||||
//! representing "now". The source of time used by this function is configurable
|
||||
//! and allows mocking out the source of time in tests or performing caching
|
||||
//! operations to reduce the number of syscalls.
|
||||
//!
|
||||
//! Note that, because the source of time is configurable, it is possible to
|
||||
//! observe non-monotonic behavior when calling [`now`][n] from different
|
||||
//! executors.
|
||||
//!
|
||||
//! [n]: fn.now.html
|
||||
|
||||
pub use crate::timer::clock::now;
|
@ -1,9 +1,9 @@
|
||||
//! Asynchronous values.
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
use crate::timer::Timeout;
|
||||
#[cfg(feature = "time")]
|
||||
use crate::time::Timeout;
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
#[cfg(feature = "time")]
|
||||
use std::time::Duration;
|
||||
|
||||
#[doc(inline)]
|
||||
@ -57,7 +57,7 @@ pub trait FutureExt: Future {
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
#[cfg(feature = "timer")]
|
||||
#[cfg(feature = "time")]
|
||||
fn timeout(self, timeout: Duration) -> Timeout<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -85,9 +85,6 @@ macro_rules! thread_local {
|
||||
($($tts:tt)+) => { loom::thread_local!{ $($tts)+ } }
|
||||
}
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
pub mod clock;
|
||||
|
||||
#[cfg(feature = "fs")]
|
||||
pub mod fs;
|
||||
|
||||
@ -117,8 +114,8 @@ pub mod stream;
|
||||
#[cfg(feature = "sync")]
|
||||
pub mod sync;
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
pub mod timer;
|
||||
#[cfg(feature = "time")]
|
||||
pub mod time;
|
||||
|
||||
#[cfg(feature = "rt-full")]
|
||||
mod util;
|
||||
|
@ -22,7 +22,7 @@ use std::fmt;
|
||||
///
|
||||
/// ```
|
||||
/// use tokio::runtime::Builder;
|
||||
/// use tokio::timer::clock::Clock;
|
||||
/// use tokio::time::clock::Clock;
|
||||
///
|
||||
/// fn main() {
|
||||
/// // build Runtime
|
||||
@ -324,7 +324,7 @@ impl Builder {
|
||||
#[cfg(feature = "rt-full")]
|
||||
fn build_threadpool(&mut self) -> io::Result<Runtime> {
|
||||
use crate::runtime::{Kind, ThreadPool};
|
||||
use crate::timer::clock;
|
||||
use crate::time::clock;
|
||||
use std::sync::Mutex;
|
||||
|
||||
let mut net_handles = Vec::new();
|
||||
|
@ -1,9 +1,9 @@
|
||||
pub(crate) use self::variant::*;
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
#[cfg(feature = "time")]
|
||||
mod variant {
|
||||
use crate::runtime::io;
|
||||
use crate::timer::{clock, timer};
|
||||
use crate::time::{clock, timer};
|
||||
|
||||
pub(crate) type Clock = clock::Clock;
|
||||
pub(crate) type Driver = timer::Timer<io::Driver>;
|
||||
@ -23,7 +23,7 @@ mod variant {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "timer"))]
|
||||
#[cfg(not(feature = "time"))]
|
||||
mod variant {
|
||||
use crate::runtime::io;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! A sequence of asynchronous values.
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
#[cfg(feature = "time")]
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(feature = "timer")]
|
||||
use crate::timer::{throttle::Throttle, Timeout};
|
||||
#[cfg(feature = "time")]
|
||||
use crate::time::{throttle::Throttle, Timeout};
|
||||
|
||||
#[doc(inline)]
|
||||
pub use futures_core::Stream;
|
||||
@ -29,7 +29,7 @@ pub trait StreamExt: Stream {
|
||||
/// Throttle down the stream by enforcing a fixed delay between items.
|
||||
///
|
||||
/// Errors are also delayed.
|
||||
#[cfg(feature = "timer")]
|
||||
#[cfg(feature = "time")]
|
||||
fn throttle(self, duration: Duration) -> Throttle<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
@ -66,7 +66,7 @@ pub trait StreamExt: Stream {
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
#[cfg(feature = "timer")]
|
||||
#[cfg(feature = "time")]
|
||||
fn timeout(self, timeout: Duration) -> Timeout<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -56,7 +56,7 @@ thread_local! {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use tokio::timer::clock;
|
||||
/// # use tokio::time::clock;
|
||||
/// let now = clock::now();
|
||||
/// ```
|
||||
pub fn now() -> Instant {
|
@ -1,4 +1,4 @@
|
||||
use crate::timer::timer::{HandlePriv, Registration};
|
||||
use crate::time::timer::{HandlePriv, Registration};
|
||||
|
||||
use futures_core::ready;
|
||||
use std::future::Future;
|
@ -4,10 +4,10 @@
|
||||
//!
|
||||
//! [`DelayQueue`]: struct.DelayQueue.html
|
||||
|
||||
use crate::timer::clock::now;
|
||||
use crate::timer::timer::Handle;
|
||||
use crate::timer::wheel::{self, Wheel};
|
||||
use crate::timer::{Delay, Error};
|
||||
use crate::time::clock::now;
|
||||
use crate::time::timer::Handle;
|
||||
use crate::time::wheel::{self, Wheel};
|
||||
use crate::time::{Delay, Error};
|
||||
|
||||
use futures_core::ready;
|
||||
use slab::Slab;
|
||||
@ -70,7 +70,7 @@ use std::time::{Duration, Instant};
|
||||
/// Using `DelayQueue` to manage cache entries.
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// use tokio::timer::{delay_queue, DelayQueue, Error};
|
||||
/// use tokio::time::{delay_queue, DelayQueue, Error};
|
||||
///
|
||||
/// use futures_core::ready;
|
||||
/// use std::collections::HashMap;
|
||||
@ -217,7 +217,7 @@ impl<T> DelayQueue<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use tokio::timer::DelayQueue;
|
||||
/// # use tokio::time::DelayQueue;
|
||||
/// let delay_queue: DelayQueue<u32> = DelayQueue::new();
|
||||
/// ```
|
||||
pub fn new() -> DelayQueue<T> {
|
||||
@ -231,8 +231,8 @@ impl<T> DelayQueue<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # use tokio::timer::DelayQueue;
|
||||
/// use tokio::timer::timer::Handle;
|
||||
/// # use tokio::time::DelayQueue;
|
||||
/// use tokio::time::timer::Handle;
|
||||
///
|
||||
/// let handle = Handle::default();
|
||||
/// let delay_queue: DelayQueue<u32> = DelayQueue::with_capacity_and_handle(0, &handle);
|
||||
@ -258,7 +258,7 @@ impl<T> DelayQueue<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use tokio::timer::DelayQueue;
|
||||
/// # use tokio::time::DelayQueue;
|
||||
/// # use std::time::Duration;
|
||||
/// let mut delay_queue = DelayQueue::with_capacity(10);
|
||||
///
|
||||
@ -302,7 +302,7 @@ impl<T> DelayQueue<T> {
|
||||
/// Basic usage
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::{Instant, Duration};
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -403,7 +403,7 @@ impl<T> DelayQueue<T> {
|
||||
/// Basic usage
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -453,7 +453,7 @@ impl<T> DelayQueue<T> {
|
||||
/// Basic usage
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -464,7 +464,7 @@ impl<T> DelayQueue<T> {
|
||||
/// assert_eq!(*item.get_ref(), "foo");
|
||||
/// ```
|
||||
pub fn remove(&mut self, key: &Key) -> Expired<T> {
|
||||
use crate::timer::wheel::Stack;
|
||||
use crate::time::wheel::Stack;
|
||||
|
||||
// Special case the `expired` queue
|
||||
if self.slab[key.index].expired {
|
||||
@ -501,7 +501,7 @@ impl<T> DelayQueue<T> {
|
||||
/// Basic usage
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::{Duration, Instant};
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -555,7 +555,7 @@ impl<T> DelayQueue<T> {
|
||||
/// Basic usage
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -582,7 +582,7 @@ impl<T> DelayQueue<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -607,7 +607,7 @@ impl<T> DelayQueue<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
///
|
||||
/// let delay_queue: DelayQueue<i32> = DelayQueue::with_capacity(10);
|
||||
/// assert_eq!(delay_queue.capacity(), 10);
|
||||
@ -636,7 +636,7 @@ impl<T> DelayQueue<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -658,7 +658,7 @@ impl<T> DelayQueue<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use tokio::timer::DelayQueue;
|
||||
/// use tokio::time::DelayQueue;
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let mut delay_queue = DelayQueue::new();
|
||||
@ -690,8 +690,7 @@ impl<T> DelayQueue<T> {
|
||||
ready!(Pin::new(&mut *delay).poll(cx));
|
||||
}
|
||||
|
||||
let now =
|
||||
crate::timer::ms(delay.deadline() - self.start, crate::timer::Round::Down);
|
||||
let now = crate::time::ms(delay.deadline() - self.start, crate::time::Round::Down);
|
||||
|
||||
self.poll = wheel::Poll::new(now);
|
||||
}
|
||||
@ -714,7 +713,7 @@ impl<T> DelayQueue<T> {
|
||||
let when = if when < self.start {
|
||||
0
|
||||
} else {
|
||||
crate::timer::ms(when - self.start, crate::timer::Round::Up)
|
||||
crate::time::ms(when - self.start, crate::time::Round::Up)
|
||||
};
|
||||
|
||||
cmp::max(when, self.wheel.elapsed())
|
@ -1,4 +1,4 @@
|
||||
use crate::timer::{clock, Delay};
|
||||
use crate::time::{clock, Delay};
|
||||
|
||||
use futures_core::ready;
|
||||
use futures_util::future::poll_fn;
|
||||
@ -39,7 +39,7 @@ impl Interval {
|
||||
|
||||
/// Creates new `Interval` that yields with interval of `duration`.
|
||||
///
|
||||
/// The function is shortcut for `Interval::new(tokio::timer::clock::now() + duration, duration)`.
|
||||
/// The function is shortcut for `Interval::new(tokio::time::clock::now() + duration, duration)`.
|
||||
///
|
||||
/// The `duration` argument must be a non-zero duration.
|
||||
///
|
||||
@ -76,7 +76,7 @@ impl Interval {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use tokio::timer::Interval;
|
||||
/// use tokio::time::Interval;
|
||||
///
|
||||
/// use std::time::Duration;
|
||||
///
|
@ -21,16 +21,14 @@
|
||||
//! involving time.
|
||||
//!
|
||||
//! These types must be used from within the context of the
|
||||
//! [`Runtime`][runtime] or a timer context must be setup explicitly. See the
|
||||
//! [`tokio-timer`][tokio-timer] crate for more details on how to setup a timer
|
||||
//! context.
|
||||
//! [`Runtime`][runtime].
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! Wait 100ms and print "Hello World!"
|
||||
//!
|
||||
//! ```
|
||||
//! use tokio::timer::delay_for;
|
||||
//! use tokio::time::delay_for;
|
||||
//!
|
||||
//! use std::time::Duration;
|
||||
//!
|
||||
@ -66,7 +64,6 @@
|
||||
//! ```
|
||||
//!
|
||||
//! [runtime]: ../runtime/struct.Runtime.html
|
||||
//! [tokio-timer]: https://docs.rs/tokio-timer
|
||||
//! [ext]: ../util/trait.FutureExt.html#method.timeout
|
||||
//! [Timeout]: struct.Timeout.html
|
||||
//! [Delay]: struct.Delay.html
|
||||
@ -82,7 +79,6 @@ pub use self::delay_queue::DelayQueue;
|
||||
pub mod throttle;
|
||||
|
||||
// TODO: clean this up
|
||||
#[allow(clippy::module_inception)]
|
||||
pub mod timer;
|
||||
pub use timer::{set_default, Timer};
|
||||
|
||||
@ -112,7 +108,7 @@ pub fn delay(deadline: Instant) -> Delay {
|
||||
|
||||
/// Create a Future that completes in `duration` from now.
|
||||
///
|
||||
/// Equivalent to `delay(tokio::timer::clock::now() + duration)`. Analogous to `std::thread::sleep`.
|
||||
/// Equivalent to `delay(tokio::time::clock::now() + duration)`. Analogous to `std::thread::sleep`.
|
||||
pub fn delay_for(duration: Duration) -> Delay {
|
||||
delay(clock::now() + duration)
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
//! Slow down a stream by enforcing a delay between items.
|
||||
|
||||
use crate::timer::{clock, Delay};
|
||||
use crate::time::{clock, Delay};
|
||||
|
||||
use futures_core::ready;
|
||||
use futures_core::Stream;
|
@ -4,8 +4,8 @@
|
||||
//!
|
||||
//! [`Timeout`]: struct.Timeout.html
|
||||
|
||||
use crate::timer::clock::now;
|
||||
use crate::timer::Delay;
|
||||
use crate::time::clock::now;
|
||||
use crate::time::Delay;
|
||||
|
||||
use futures_core::ready;
|
||||
use std::fmt;
|
||||
@ -95,7 +95,7 @@ impl<T> Timeout<T> {
|
||||
/// Create a new `Timeout` set to expire in 10 milliseconds.
|
||||
///
|
||||
/// ```rust
|
||||
/// use tokio::timer::Timeout;
|
||||
/// use tokio::time::Timeout;
|
||||
/// use tokio::sync::oneshot;
|
||||
///
|
||||
/// use std::time::Duration;
|
@ -1,5 +1,5 @@
|
||||
use super::Entry;
|
||||
use crate::timer::Error;
|
||||
use crate::time::timer::Entry;
|
||||
use crate::time::Error;
|
||||
|
||||
use std::ptr;
|
||||
use std::sync::atomic::AtomicPtr;
|
@ -1,7 +1,7 @@
|
||||
use crate::sync::AtomicWaker;
|
||||
use crate::timer::atomic::AtomicU64;
|
||||
use crate::timer::timer::{HandlePriv, Inner};
|
||||
use crate::timer::Error;
|
||||
use crate::time::atomic::AtomicU64;
|
||||
use crate::time::timer::{HandlePriv, Inner};
|
||||
use crate::time::Error;
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
use std::ptr;
|
@ -1,6 +1,6 @@
|
||||
use crate::timer::clock::now;
|
||||
use crate::timer::timer::Inner;
|
||||
use crate::timer::{Delay, Error, Timeout};
|
||||
use crate::time::clock::now;
|
||||
use crate::time::timer::Inner;
|
||||
use crate::time::{Delay, Error, Timeout};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fmt;
|
@ -42,10 +42,10 @@ mod stack;
|
||||
use self::stack::Stack;
|
||||
|
||||
use crate::runtime::{Park, Unpark};
|
||||
use crate::timer::atomic::AtomicU64;
|
||||
use crate::timer::clock::Clock;
|
||||
use crate::timer::wheel;
|
||||
use crate::timer::Error;
|
||||
use crate::time::atomic::AtomicU64;
|
||||
use crate::time::clock::Clock;
|
||||
use crate::time::wheel;
|
||||
use crate::time::Error;
|
||||
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering::SeqCst;
|
||||
@ -257,9 +257,9 @@ where
|
||||
|
||||
/// Run timer related logic
|
||||
fn process(&mut self) {
|
||||
let now = crate::timer::ms(
|
||||
let now = crate::time::ms(
|
||||
self.clock.now() - self.inner.start,
|
||||
crate::timer::Round::Down,
|
||||
crate::time::Round::Down,
|
||||
);
|
||||
let mut poll = wheel::Poll::new(now);
|
||||
|
||||
@ -311,7 +311,7 @@ where
|
||||
///
|
||||
/// Returns `None` if the entry was fired.
|
||||
fn add_entry(&mut self, entry: Arc<Entry>, when: u64) {
|
||||
use crate::timer::wheel::InsertError;
|
||||
use crate::time::wheel::InsertError;
|
||||
|
||||
entry.set_when_internal(Some(when));
|
||||
|
||||
@ -466,7 +466,7 @@ impl Inner {
|
||||
return 0;
|
||||
}
|
||||
|
||||
crate::timer::ms(deadline - self.start, crate::timer::Round::Up)
|
||||
crate::time::ms(deadline - self.start, crate::time::Round::Up)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::timer::timer::{Entry, HandlePriv};
|
||||
use crate::timer::Error;
|
||||
use crate::time::timer::{Entry, HandlePriv};
|
||||
use crate::time::Error;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::task::{self, Poll};
|
||||
@ -47,7 +47,7 @@ impl Registration {
|
||||
|
||||
// Used by `Timeout<Stream>`
|
||||
pub(crate) fn reset_timeout(&mut self) {
|
||||
let deadline = crate::clock::now() + self.entry.time_ref().duration;
|
||||
let deadline = crate::time::clock::now() + self.entry.time_ref().duration;
|
||||
unsafe {
|
||||
self.entry.time_mut().deadline = deadline;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
use crate::timer::timer::Entry;
|
||||
use crate::timer::wheel;
|
||||
use crate::time::timer::Entry;
|
||||
use crate::time::wheel;
|
||||
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
@ -1,4 +1,4 @@
|
||||
use crate::timer::wheel::Stack;
|
||||
use crate::time::wheel::Stack;
|
||||
|
||||
use std::fmt;
|
||||
|
@ -1,15 +1,15 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::runtime;
|
||||
use tokio::timer::clock::Clock;
|
||||
use tokio::timer::*;
|
||||
use tokio::time::clock::Clock;
|
||||
use tokio::time::*;
|
||||
|
||||
use std::sync::mpsc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
struct MockNow(Instant);
|
||||
|
||||
impl tokio::timer::clock::Now for MockNow {
|
||||
impl tokio::time::clock::Now for MockNow {
|
||||
fn now(&self) -> Instant {
|
||||
self.0
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ rt_test! {
|
||||
use tokio::prelude::*;
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio::sync::oneshot;
|
||||
use tokio::timer;
|
||||
use tokio::time;
|
||||
use tokio_test::{assert_err, assert_ok};
|
||||
|
||||
use futures_util::future::poll_fn;
|
||||
@ -289,7 +289,7 @@ rt_test! {
|
||||
let dur = Duration::from_millis(50);
|
||||
|
||||
rt.block_on(async move {
|
||||
timer::delay_for(dur).await;
|
||||
time::delay_for(dur).await;
|
||||
});
|
||||
|
||||
assert!(now.elapsed() >= dur);
|
||||
@ -306,7 +306,7 @@ rt_test! {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
tokio::spawn(async move {
|
||||
timer::delay_for(dur).await;
|
||||
time::delay_for(dur).await;
|
||||
assert_ok!(tx.send(()));
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::timer::clock;
|
||||
use tokio::timer::clock::*;
|
||||
use tokio::time::clock;
|
||||
use tokio::time::clock::*;
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::timer::delay;
|
||||
use tokio::timer::timer::Handle;
|
||||
use tokio::time::delay;
|
||||
use tokio::time::timer::Handle;
|
||||
use tokio_test::task;
|
||||
use tokio_test::{assert_pending, assert_ready, clock};
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
use tokio::executor::park::{Park, Unpark, UnparkThread};
|
||||
use tokio::runtime;
|
||||
use tokio::timer::{Delay, Timer};
|
||||
use tokio::time::{Delay, Timer};
|
||||
|
||||
use rand::Rng;
|
||||
use std::cmp;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::timer::*;
|
||||
use tokio::time::*;
|
||||
use tokio_test::task;
|
||||
use tokio_test::{assert_pending, assert_ready_eq, clock};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::timer::*;
|
||||
use tokio::time::*;
|
||||
use tokio_test::{assert_ok, assert_pending, assert_ready};
|
||||
use tokio_test::{clock, task};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::prelude::*;
|
||||
use tokio::timer::*;
|
||||
use tokio::time::*;
|
||||
|
||||
use std::sync::mpsc;
|
||||
use std::time::{Duration, Instant};
|
||||
@ -35,7 +35,7 @@ fn timer_with_current_thread_runtime() {
|
||||
rt.block_on(async move {
|
||||
let when = Instant::now() + Duration::from_millis(100);
|
||||
|
||||
tokio::timer::delay(when).await;
|
||||
tokio::time::delay(when).await;
|
||||
assert!(Instant::now() >= when);
|
||||
|
||||
tx.send(()).unwrap();
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::timer::throttle::Throttle;
|
||||
use tokio::time::throttle::Throttle;
|
||||
use tokio_test::task;
|
||||
use tokio_test::{assert_pending, assert_ready_eq, clock};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::sync::oneshot;
|
||||
use tokio::timer::*;
|
||||
use tokio::time::*;
|
||||
use tokio_test::task;
|
||||
use tokio_test::{
|
||||
assert_err, assert_pending, assert_ready, assert_ready_err, assert_ready_ok, clock,
|
||||
|
Loading…
x
Reference in New Issue
Block a user