Skip to content

Commit

Permalink
Move from tokio 0.3 to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Dec 23, 2020
1 parent 9188ef7 commit b2b1400
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ jobs:
rustup target add wasm32-unknown-unknown
cargo check --target wasm32-unknown-unknown
- name: Test with tokio 0.3
- name: Test with tokio 1.0
if: runner.os != 'Windows'
run: cargo test --features tokio03 -- --nocapture
run: cargo test --features tokio1 -- --nocapture

- name: Test
run: cargo test --all --features std,stream
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "async-timer"
version = "1.0.0-beta.6"
version = "1.0.0-beta.7"
authors = ["Douman <[email protected]>"]
edition = "2018"
description = "Timers for Rust async story"
Expand All @@ -22,8 +22,8 @@ default = []
std = []
# Enables C API wrapper for platform code.
c_wrapper = ["cc"]
# Enables usage of tokio 0.3
tokio03 = ["tokio_03", "nix", "std"]
# Enables usage of tokio 1.0
tokio1 = ["tokio_1", "nix", "std"]
# Enables Stream implementation
stream = ["futures-core"]

Expand All @@ -41,7 +41,7 @@ features = ["threadpoolapiset"]

[target.'cfg(any(target_os = "macos", target_os = "ios", unix))'.dependencies]
libc = { version = "0.2.60", default-features = false }
tokio_03 = { package = "tokio", version = "0.3.5", default-features = false, optional = true, features = ["net"] }
tokio_1 = { package = "tokio", version = "1", default-features = false, optional = true, features = ["net"] }

#kqueue needs nix
[target.'cfg(any(target_os = "bitrig", target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
Expand All @@ -51,7 +51,7 @@ nix = { version = "0.19", optional = true }
wasm-bindgen = "0.2"

[dev-dependencies]
tokio_03 = { package = "tokio", version = "0.3.2", default-features = false, features = ["macros", "rt"] }
tokio_1 = { package = "tokio", version = "1", default-features = false, features = ["macros", "rt"] }

[build-dependencies.cc]
version = "1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ give you the most accurate timers possible on unix platforms (See features.)

## Features

- `tokio03` - Enables event loop based timers using tokio 0.3, providing higher resolution timers on unix platforms.
- `tokio1` - Enables event loop based timers using tokio, providing higher resolution timers on unix platforms.
- `c_wrapper` - Uses C shim to create bindings to platform API, which may be more reliable than `libc`.
- `std` - Enables usage of std types (e.g. Error)
- `stream` - Enables `Stream` implementation for `Interval`
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//!
//! ## Features
//!
//! - `tokio03` - Enables event loop based timers using tokio 0.3, providing higher resolution timers on unix platforms.
//! - `tokio1` - Enables event loop based timers using tokio, providing higher resolution timers on unix platforms.
//! - `c_wrapper` - Uses C shim to create bindings to platform API, which may be more reliable than `libc`.
//! - `std` - Enables usage of std types (e.g. Error)
//! - `stream` - Enables `Stream` implementation for `Interval`
Expand Down
2 changes: 1 addition & 1 deletion src/timer/async_tokio03.rs → src/timer/async_tokio1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use tokio_03 as tokio;
use tokio_1 as tokio;

use tokio::io::unix::AsyncFd;
use libc::{c_int};
Expand Down
14 changes: 7 additions & 7 deletions src/timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ pub type Platform = win::WinTimer;
///Platform alias to Windows timer
pub type SyncPlatform = win::WinTimer;

#[cfg(all(feature = "tokio03", unix))]
mod async_tokio03;
#[cfg(all(feature = "tokio03", unix))]
pub use async_tokio03::AsyncTimer;
#[cfg(all(feature = "tokio03", unix))]
#[cfg(all(feature = "tokio1", unix))]
mod async_tokio1;
#[cfg(all(feature = "tokio1", unix))]
pub use async_tokio1::AsyncTimer;
#[cfg(all(feature = "tokio1", unix))]
///Timer based on tokio's `AsyncFd`
pub type Platform = AsyncTimer;

#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
mod posix;
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
pub use posix::PosixTimer;
#[cfg(all(not(feature = "tokio03"), not(any(target_os = "macos", target_os = "ios")), unix))]
#[cfg(all(not(feature = "tokio1"), not(any(target_os = "macos", target_os = "ios")), unix))]
///Platform alias to POSIX timer
pub type Platform = posix::PosixTimer;
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
Expand All @@ -162,7 +162,7 @@ pub type SyncPlatform = posix::PosixTimer;
mod apple;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub use apple::AppleTimer;
#[cfg(all(not(feature = "tokio03"), any(target_os = "macos", target_os = "ios")))]
#[cfg(all(not(feature = "tokio1"), any(target_os = "macos", target_os = "ios")))]
///Platform alias to Apple Dispatch timer
pub type Platform = apple::AppleTimer;
#[cfg(any(target_os = "macos", target_os = "ios"))]
Expand Down
2 changes: 1 addition & 1 deletion tests/interval.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_timer::{Interval};
use tokio_03 as tokio;
use tokio_1 as tokio;

use std::time;

Expand Down
2 changes: 1 addition & 1 deletion tests/timed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::pin::Pin;
use tokio_03 as tokio;
use tokio_1 as tokio;

use std::time;

Expand Down
2 changes: 1 addition & 1 deletion tests/timer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_timer::timer::{Timer, Platform, SyncTimer, new_sync_timer};
use tokio_03 as tokio;
use tokio_1 as tokio;

use std::time;

Expand Down

0 comments on commit b2b1400

Please sign in to comment.