mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
timer: move tokio-timer into tokio crate (#1674)
A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The `timer` implementation is now provided by the main `tokio` crate. The `timer` functionality may still be excluded from the build by skipping the `timer` feature flag.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//! A mocked clock for use with `tokio_timer` based futures.
|
||||
//! A mocked clock for use with `tokio::timer` based futures.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! use tokio::clock;
|
||||
//! use tokio::timer::delay;
|
||||
//! use tokio_test::{assert_ready, assert_pending, task};
|
||||
//! use tokio_timer::delay;
|
||||
//!
|
||||
//! use std::time::Duration;
|
||||
//!
|
||||
@@ -22,9 +22,9 @@
|
||||
//! });
|
||||
//! ```
|
||||
|
||||
use tokio::timer::clock::{Clock, Now};
|
||||
use tokio::timer::Timer;
|
||||
use tokio_executor::park::{Park, Unpark};
|
||||
use tokio_timer::clock::{Clock, Now};
|
||||
use tokio_timer::Timer;
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
@@ -125,13 +125,13 @@ impl MockClock {
|
||||
where
|
||||
F: FnOnce(&mut Handle) -> R,
|
||||
{
|
||||
::tokio_timer::clock::with_default(&self.clock, || {
|
||||
tokio::timer::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::timer::set_default(&handle);
|
||||
let mut handle = Handle::new(timer, time);
|
||||
f(&mut handle)
|
||||
// lazy(|| Ok::<_, ()>(f(&mut handle))).wait().unwrap()
|
||||
|
||||
+5
-41
@@ -16,6 +16,11 @@
|
||||
//! [`AsyncRead`]: tokio_io::AsyncRead
|
||||
//! [`AsyncWrite`]: tokio_io::AsyncWrite
|
||||
|
||||
use tokio::timer::{clock, timer, Delay};
|
||||
use tokio_io::{AsyncRead, AsyncWrite, Buf};
|
||||
use tokio_sync::mpsc;
|
||||
|
||||
use futures_core::ready;
|
||||
use std::collections::VecDeque;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
@@ -23,11 +28,6 @@ use std::task::{self, Poll, Waker};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{cmp, io};
|
||||
|
||||
use futures_core::ready;
|
||||
use tokio_io::{AsyncRead, AsyncWrite, Buf};
|
||||
use tokio_sync::mpsc;
|
||||
use tokio_timer::{clock, timer, Delay};
|
||||
|
||||
/// An I/O object that follows a predefined script.
|
||||
///
|
||||
/// This value is created by `Builder` and implements `AsyncRead` + `AsyncWrite`. It
|
||||
@@ -268,42 +268,6 @@ impl Inner {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
impl io::Read for Mock {
|
||||
fn read(&mut self, dst: &mut [u8]) -> io::Result<usize> {
|
||||
if self.is_async() {
|
||||
tokio::async_read(self, dst)
|
||||
} else {
|
||||
self.sync_read(dst)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Write for Mock {
|
||||
fn write(&mut self, src: &[u8]) -> io::Result<usize> {
|
||||
if self.is_async() {
|
||||
tokio::async_write(self, src)
|
||||
} else {
|
||||
self.sync_write(src)
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
use self::futures::{Future, Stream, Poll, Async};
|
||||
use self::futures::sync::mpsc;
|
||||
use self::futures::task::{self, Task};
|
||||
use self::tokio_io::{AsyncRead, AsyncWrite};
|
||||
use self::tokio_timer::{Timer, Sleep};
|
||||
|
||||
use std::io;
|
||||
*/
|
||||
|
||||
// ===== impl Inner =====
|
||||
|
||||
impl Mock {
|
||||
|
||||
Reference in New Issue
Block a user