diff --git a/tokio-test/src/clock.rs b/tokio-test/src/clock.rs index 38417539e..d2f292491 100644 --- a/tokio-test/src/clock.rs +++ b/tokio-test/src/clock.rs @@ -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() diff --git a/tokio-test/src/io.rs b/tokio-test/src/io.rs index afd1c423e..a073193c4 100644 --- a/tokio-test/src/io.rs +++ b/tokio-test/src/io.rs @@ -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; diff --git a/tokio-test/tests/block_on.rs b/tokio-test/tests/block_on.rs index 6d5f481a4..c361d5008 100644 --- a/tokio-test/tests/block_on.rs +++ b/tokio-test/tests/block_on.rs @@ -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}; diff --git a/tokio-test/tests/clock.rs b/tokio-test/tests/clock.rs index abb61e232..d9d2fcfc2 100644 --- a/tokio-test/tests/clock.rs +++ b/tokio-test/tests/clock.rs @@ -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}; diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 58d7cecc3..df2841724 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -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 = [ diff --git a/tokio/src/clock.rs b/tokio/src/clock.rs deleted file mode 100644 index d574af857..000000000 --- a/tokio/src/clock.rs +++ /dev/null @@ -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; diff --git a/tokio/src/future.rs b/tokio/src/future.rs index 2a714a3e0..f6b7e4a71 100644 --- a/tokio/src/future.rs +++ b/tokio/src/future.rs @@ -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 where Self: Sized, diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index b7b99ac6d..8f9736ea0 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -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; diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 6081c10e1..3a81af3e5 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -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 { use crate::runtime::{Kind, ThreadPool}; - use crate::timer::clock; + use crate::time::clock; use std::sync::Mutex; let mut net_handles = Vec::new(); diff --git a/tokio/src/runtime/timer.rs b/tokio/src/runtime/timer.rs index 987324cd2..03e501ce5 100644 --- a/tokio/src/runtime/timer.rs +++ b/tokio/src/runtime/timer.rs @@ -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; @@ -23,7 +23,7 @@ mod variant { } } -#[cfg(not(feature = "timer"))] +#[cfg(not(feature = "time"))] mod variant { use crate::runtime::io; diff --git a/tokio/src/stream.rs b/tokio/src/stream.rs index e4f5a1b1f..0a597a58f 100644 --- a/tokio/src/stream.rs +++ b/tokio/src/stream.rs @@ -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 where Self: Sized, @@ -66,7 +66,7 @@ pub trait StreamExt: Stream { /// } /// # } /// ``` - #[cfg(feature = "timer")] + #[cfg(feature = "time")] fn timeout(self, timeout: Duration) -> Timeout where Self: Sized, diff --git a/tokio/src/timer/atomic.rs b/tokio/src/time/atomic.rs similarity index 100% rename from tokio/src/timer/atomic.rs rename to tokio/src/time/atomic.rs diff --git a/tokio/src/timer/clock/mod.rs b/tokio/src/time/clock/mod.rs similarity index 99% rename from tokio/src/timer/clock/mod.rs rename to tokio/src/time/clock/mod.rs index df2f21339..17cbe2f9b 100644 --- a/tokio/src/timer/clock/mod.rs +++ b/tokio/src/time/clock/mod.rs @@ -56,7 +56,7 @@ thread_local! { /// # Examples /// /// ``` -/// # use tokio::timer::clock; +/// # use tokio::time::clock; /// let now = clock::now(); /// ``` pub fn now() -> Instant { diff --git a/tokio/src/timer/clock/now.rs b/tokio/src/time/clock/now.rs similarity index 100% rename from tokio/src/timer/clock/now.rs rename to tokio/src/time/clock/now.rs diff --git a/tokio/src/timer/deadline.rs b/tokio/src/time/deadline.rs similarity index 100% rename from tokio/src/timer/deadline.rs rename to tokio/src/time/deadline.rs diff --git a/tokio/src/timer/delay.rs b/tokio/src/time/delay.rs similarity index 98% rename from tokio/src/timer/delay.rs rename to tokio/src/time/delay.rs index a4e9e3252..e79f9c341 100644 --- a/tokio/src/timer/delay.rs +++ b/tokio/src/time/delay.rs @@ -1,4 +1,4 @@ -use crate::timer::timer::{HandlePriv, Registration}; +use crate::time::timer::{HandlePriv, Registration}; use futures_core::ready; use std::future::Future; diff --git a/tokio/src/timer/delay_queue.rs b/tokio/src/time/delay_queue.rs similarity index 96% rename from tokio/src/timer/delay_queue.rs rename to tokio/src/time/delay_queue.rs index 70cc74e5a..38d049403 100644 --- a/tokio/src/timer/delay_queue.rs +++ b/tokio/src/time/delay_queue.rs @@ -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 DelayQueue { /// # Examples /// /// ```rust - /// # use tokio::timer::DelayQueue; + /// # use tokio::time::DelayQueue; /// let delay_queue: DelayQueue = DelayQueue::new(); /// ``` pub fn new() -> DelayQueue { @@ -231,8 +231,8 @@ impl DelayQueue { /// # 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 = DelayQueue::with_capacity_and_handle(0, &handle); @@ -258,7 +258,7 @@ impl DelayQueue { /// # 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 DelayQueue { /// 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 DelayQueue { /// 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 DelayQueue { /// 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 DelayQueue { /// assert_eq!(*item.get_ref(), "foo"); /// ``` pub fn remove(&mut self, key: &Key) -> Expired { - 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 DelayQueue { /// 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 DelayQueue { /// 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 DelayQueue { /// # 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 DelayQueue { /// # Examples /// /// ```rust - /// use tokio::timer::DelayQueue; + /// use tokio::time::DelayQueue; /// /// let delay_queue: DelayQueue = DelayQueue::with_capacity(10); /// assert_eq!(delay_queue.capacity(), 10); @@ -636,7 +636,7 @@ impl DelayQueue { /// # Examples /// /// ``` - /// use tokio::timer::DelayQueue; + /// use tokio::time::DelayQueue; /// use std::time::Duration; /// /// let mut delay_queue = DelayQueue::new(); @@ -658,7 +658,7 @@ impl DelayQueue { /// # Examples /// /// ``` - /// use tokio::timer::DelayQueue; + /// use tokio::time::DelayQueue; /// use std::time::Duration; /// /// let mut delay_queue = DelayQueue::new(); @@ -690,8 +690,7 @@ impl DelayQueue { 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 DelayQueue { 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()) diff --git a/tokio/src/timer/error.rs b/tokio/src/time/error.rs similarity index 100% rename from tokio/src/timer/error.rs rename to tokio/src/time/error.rs diff --git a/tokio/src/timer/interval.rs b/tokio/src/time/interval.rs similarity index 94% rename from tokio/src/timer/interval.rs rename to tokio/src/time/interval.rs index de0c1ba5c..f517b23f3 100644 --- a/tokio/src/timer/interval.rs +++ b/tokio/src/time/interval.rs @@ -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; /// diff --git a/tokio/src/timer/mod.rs b/tokio/src/time/mod.rs similarity index 89% rename from tokio/src/timer/mod.rs rename to tokio/src/time/mod.rs index 5af959244..d6f1e0de1 100644 --- a/tokio/src/timer/mod.rs +++ b/tokio/src/time/mod.rs @@ -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) } diff --git a/tokio/src/timer/throttle.rs b/tokio/src/time/throttle.rs similarity index 98% rename from tokio/src/timer/throttle.rs rename to tokio/src/time/throttle.rs index 5c46adde6..5572c0b89 100644 --- a/tokio/src/timer/throttle.rs +++ b/tokio/src/time/throttle.rs @@ -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; diff --git a/tokio/src/timer/timeout.rs b/tokio/src/time/timeout.rs similarity index 98% rename from tokio/src/timer/timeout.rs rename to tokio/src/time/timeout.rs index 7d028aa68..e1fdb252e 100644 --- a/tokio/src/timer/timeout.rs +++ b/tokio/src/time/timeout.rs @@ -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 Timeout { /// 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; diff --git a/tokio/src/timer/timer/atomic_stack.rs b/tokio/src/time/timer/atomic_stack.rs similarity index 98% rename from tokio/src/timer/timer/atomic_stack.rs rename to tokio/src/time/timer/atomic_stack.rs index 849e79a33..fc73943ba 100644 --- a/tokio/src/timer/timer/atomic_stack.rs +++ b/tokio/src/time/timer/atomic_stack.rs @@ -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; diff --git a/tokio/src/timer/timer/entry.rs b/tokio/src/time/timer/entry.rs similarity index 99% rename from tokio/src/timer/timer/entry.rs rename to tokio/src/time/timer/entry.rs index 7c653ad90..b189b2f6b 100644 --- a/tokio/src/timer/timer/entry.rs +++ b/tokio/src/time/timer/entry.rs @@ -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; diff --git a/tokio/src/timer/timer/handle.rs b/tokio/src/time/timer/handle.rs similarity index 98% rename from tokio/src/timer/timer/handle.rs rename to tokio/src/time/timer/handle.rs index 515cc877b..044c4aba8 100644 --- a/tokio/src/timer/timer/handle.rs +++ b/tokio/src/time/timer/handle.rs @@ -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; diff --git a/tokio/src/timer/timer/mod.rs b/tokio/src/time/timer/mod.rs similarity index 97% rename from tokio/src/timer/timer/mod.rs rename to tokio/src/time/timer/mod.rs index cce30b668..e79f1f378 100644 --- a/tokio/src/timer/timer/mod.rs +++ b/tokio/src/time/timer/mod.rs @@ -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, 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) } } diff --git a/tokio/src/timer/timer/now.rs b/tokio/src/time/timer/now.rs similarity index 100% rename from tokio/src/timer/timer/now.rs rename to tokio/src/time/timer/now.rs diff --git a/tokio/src/timer/timer/registration.rs b/tokio/src/time/timer/registration.rs similarity index 91% rename from tokio/src/timer/timer/registration.rs rename to tokio/src/time/timer/registration.rs index 9dceb3c66..1911fd520 100644 --- a/tokio/src/timer/timer/registration.rs +++ b/tokio/src/time/timer/registration.rs @@ -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` 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; } diff --git a/tokio/src/timer/timer/stack.rs b/tokio/src/time/timer/stack.rs similarity index 98% rename from tokio/src/timer/timer/stack.rs rename to tokio/src/time/timer/stack.rs index 41ae33ed3..763aa0ab8 100644 --- a/tokio/src/timer/timer/stack.rs +++ b/tokio/src/time/timer/stack.rs @@ -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; diff --git a/tokio/src/timer/wheel/level.rs b/tokio/src/time/wheel/level.rs similarity index 99% rename from tokio/src/timer/wheel/level.rs rename to tokio/src/time/wheel/level.rs index 256ed4a73..73eab6ce5 100644 --- a/tokio/src/timer/wheel/level.rs +++ b/tokio/src/time/wheel/level.rs @@ -1,4 +1,4 @@ -use crate::timer::wheel::Stack; +use crate::time::wheel::Stack; use std::fmt; diff --git a/tokio/src/timer/wheel/mod.rs b/tokio/src/time/wheel/mod.rs similarity index 100% rename from tokio/src/timer/wheel/mod.rs rename to tokio/src/time/wheel/mod.rs diff --git a/tokio/src/timer/wheel/stack.rs b/tokio/src/time/wheel/stack.rs similarity index 100% rename from tokio/src/timer/wheel/stack.rs rename to tokio/src/time/wheel/stack.rs diff --git a/tokio/tests/clock.rs b/tokio/tests/clock.rs index a9c2e3d29..ff949eac9 100644 --- a/tokio/tests/clock.rs +++ b/tokio/tests/clock.rs @@ -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 } diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs index e26a5e4fe..d6c1b1fd0 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -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(())); }); diff --git a/tokio/tests/timer_clock.rs b/tokio/tests/timer_clock.rs index 686fb2b1f..2dc45dae9 100644 --- a/tokio/tests/timer_clock.rs +++ b/tokio/tests/timer_clock.rs @@ -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; diff --git a/tokio/tests/timer_delay.rs b/tokio/tests/timer_delay.rs index 3d67890b8..185067497 100644 --- a/tokio/tests/timer_delay.rs +++ b/tokio/tests/timer_delay.rs @@ -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}; diff --git a/tokio/tests/timer_hammer.rs b/tokio/tests/timer_hammer.rs index 764cb97a8..6f1ad98ea 100644 --- a/tokio/tests/timer_hammer.rs +++ b/tokio/tests/timer_hammer.rs @@ -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; diff --git a/tokio/tests/timer_interval.rs b/tokio/tests/timer_interval.rs index 4542ecf37..d15140f55 100644 --- a/tokio/tests/timer_interval.rs +++ b/tokio/tests/timer_interval.rs @@ -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}; diff --git a/tokio/tests/timer_queue.rs b/tokio/tests/timer_queue.rs index f1a7bae07..118f86f3e 100644 --- a/tokio/tests/timer_queue.rs +++ b/tokio/tests/timer_queue.rs @@ -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}; diff --git a/tokio/tests/timer_rt.rs b/tokio/tests/timer_rt.rs index 8e9026e4b..ef337e590 100644 --- a/tokio/tests/timer_rt.rs +++ b/tokio/tests/timer_rt.rs @@ -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(); diff --git a/tokio/tests/timer_throttle.rs b/tokio/tests/timer_throttle.rs index 7667cd7d4..e119ff937 100644 --- a/tokio/tests/timer_throttle.rs +++ b/tokio/tests/timer_throttle.rs @@ -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}; diff --git a/tokio/tests/timer_timeout.rs b/tokio/tests/timer_timeout.rs index 8df56f4d3..0bc135d8e 100644 --- a/tokio/tests/timer_timeout.rs +++ b/tokio/tests/timer_timeout.rs @@ -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,