diff options
author | Carl Lerche <me@carllerche.com> | 2019-11-12 15:23:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-12 15:23:40 -0800 |
commit | 27e5b41067d01c0c9fac230c5addb58034201a63 (patch) | |
tree | f9bd8333dfe1853dfe1d8710b4dc966bd8555d54 /tokio-test/tests | |
parent | e3df2eafd32e6f813d08617f0e2cd7abbc05c2b1 (diff) |
reorganize modules (#1766)
This patch started as an effort to make `time::Timer` private. However, in an
effort to get the build compiling again, more and more changes were made. This
probably should have been broken up, but here we are. I will attempt to
summarize the changes here.
* Feature flags are reorganized to make clearer. `net-driver` becomes
`io-driver`. `rt-current-thread` becomes `rt-core`.
* The `Runtime` can be created without any executor. This replaces `enter`. It
also allows creating I/O / time drivers that are standalone.
* `tokio::timer` is renamed to `tokio::time`. This brings it in line with `std`.
* `tokio::timer::Timer` is renamed to `Driver` and made private.
* The `clock` module is removed. Instead, an `Instant` type is provided. This
type defaults to calling `std::time::Instant`. A `test-util` feature flag can
be used to enable hooking into time.
* The `blocking` module is moved to the top level and is cleaned up.
* The `task` module is moved to the top level.
* The thread-pool's in-place blocking implementation is cleaned up.
* `runtime::Spawner` is renamed to `runtime::Handle` and can be used to "enter"
a runtime context.
Diffstat (limited to 'tokio-test/tests')
-rw-r--r-- | tokio-test/tests/block_on.rs | 4 | ||||
-rw-r--r-- | tokio-test/tests/clock.rs | 25 |
2 files changed, 1 insertions, 28 deletions
diff --git a/tokio-test/tests/block_on.rs b/tokio-test/tests/block_on.rs index c361d500..3c0fe32f 100644 --- a/tokio-test/tests/block_on.rs +++ b/tokio-test/tests/block_on.rs @@ -1,10 +1,8 @@ #![warn(rust_2018_idioms)] -use tokio::time::delay; +use tokio::time::{delay, Duration, Instant}; use tokio_test::block_on; -use std::time::{Duration, Instant}; - #[test] fn async_block() { assert_eq!(4, block_on(async { 4 })); diff --git a/tokio-test/tests/clock.rs b/tokio-test/tests/clock.rs deleted file mode 100644 index d9d2fcfc..00000000 --- a/tokio-test/tests/clock.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![warn(rust_2018_idioms)] - -use tokio::time::delay; -use tokio_test::clock::MockClock; -use tokio_test::task; -use tokio_test::{assert_pending, assert_ready}; - -use std::time::{Duration, Instant}; - -#[test] -fn clock() { - let mut mock = MockClock::new(); - - mock.enter(|handle| { - let deadline = Instant::now() + Duration::from_secs(1); - let mut delay = task::spawn(delay(deadline)); - - assert_pending!(delay.poll()); - - handle.advance(Duration::from_secs(2)); - - assert!(delay.is_woken()); - assert_ready!(delay.poll()); - }); -} |