Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Tokio to Rust 2018 #1082

Merged
merged 46 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
50dab6f
async-await: replace std await! macro with await syntax
taiki-e May 9, 2019
91c69db
buf, io: update to Rust 2018
carllerche May 9, 2019
429851f
io: fix tests
carllerche May 9, 2019
cd260eb
sync: update to Rust 2018
carllerche May 9, 2019
9acaec4
executor: update to Rust 2018
carllerche May 9, 2019
ec682c5
reactor: update to Rust 2018
carllerche May 9, 2019
72a09e0
macros: tweaks
carllerche May 9, 2019
4f771a6
async-await: replace std_await! macro with await syntax
taiki-e May 9, 2019
29da8ac
codec: update to Rust 2018
carllerche May 9, 2019
908304c
current-thread: update to Rust 2018
carllerche May 9, 2019
4de9e11
threadpool: update to Rust 2018
carllerche May 9, 2019
6bd15b7
async-await: rename tokio::await! to async_wait!
taiki-e May 9, 2019
4d12639
all: update Cargo.toml versions + disable push
carllerche May 9, 2019
bf9c201
update dep versions in Cargo.toml files
carllerche May 9, 2019
df9a87f
fs: update to Rust 2018
carllerche May 10, 2019
d387ae7
Merge remote-tracking branch 'taiki-e/await' into rust-2018
carllerche May 10, 2019
7e9217f
futures: update to Rust 2018
carllerche May 10, 2019
3416d87
signal: update to Rust 2018
carllerche May 10, 2019
a19c118
tcp: update to Rust 2018
carllerche May 10, 2019
73ab0ef
timer: update to Rust 2018
carllerche May 10, 2019
6e68380
test: update to Rust 2018
carllerche May 10, 2019
814d876
tls: update to Rust 2018
carllerche May 10, 2019
95b8eee
udp: update to Rust 2018
carllerche May 10, 2019
05d348a
uds: update to Rust 2018
carllerche May 10, 2019
d2040b3
tokio: update to Rust 2018
carllerche May 10, 2019
d8a0b1f
fmt
carllerche May 10, 2019
55f7c74
fmt
carllerche May 10, 2019
611ade4
windows fixes
carllerche May 10, 2019
7cf9f86
linux fix
carllerche May 10, 2019
2a32934
misc ci fixes
carllerche May 10, 2019
6641f6c
misc fixes
carllerche May 10, 2019
0a12f4b
More fixes
carllerche May 10, 2019
778f9a0
win fix
carllerche May 10, 2019
3ea50d2
win fix
carllerche May 10, 2019
dbf3e3b
tsan whitelist
carllerche May 10, 2019
c33584d
more tsan whitelist
carllerche May 10, 2019
cd59434
Update tokio-signal/src/windows.rs
carllerche May 10, 2019
c84c285
Deny rust_2018_idioms for tokio doc tests
carllerche May 10, 2019
1505f8d
Work on updating docs
carllerche May 10, 2019
b3ffa7f
fs, io: update doc examples
carllerche May 10, 2019
2628120
more doc fixes
carllerche May 10, 2019
d6ed92e
more doc fixes
carllerche May 10, 2019
360ee74
hopefully all doc tests are updated
carllerche May 10, 2019
395b884
fmt
carllerche May 10, 2019
5152abb
Fix examples
carllerche May 10, 2019
ca8fa97
fix docs
carllerche May 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
threadpool: update to Rust 2018
  • Loading branch information
carllerche committed May 9, 2019
commit 4de9e1198108f66055ac427e12efc3cf34a91852
2 changes: 2 additions & 0 deletions tokio-threadpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ name = "tokio-threadpool"
# - Update CHANGELOG.md.
# - Create "v0.1.x" git tag.
version = "0.1.14"
edition = "2018"
documentation = "https://docs.rs/tokio-threadpool/0.1.14/tokio_threadpool"
repository = "https://github.com/tokio-rs/tokio"
homepage = "https://github.com/tokio-rs/tokio"
Expand All @@ -19,6 +20,7 @@ A task scheduler backed by a work-stealing thread pool.
"""
keywords = ["futures", "tokio"]
categories = ["concurrency", "asynchronous"]
publish = false

[dependencies]
tokio-executor = "0.1.7"
Expand Down
10 changes: 2 additions & 8 deletions tokio-threadpool/benches/basic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#![feature(test)]
#![deny(warnings)]
#![deny(warnings, rust_2018_idioms)]

extern crate futures;
extern crate futures_cpupool;
extern crate num_cpus;
extern crate test;
extern crate tokio_threadpool;

const NUM_SPAWN: usize = 10_000;
const NUM_YIELD: usize = 1_000;
Expand All @@ -14,11 +10,10 @@ const TASKS_PER_CPU: usize = 50;
mod threadpool {
use futures::{future, task, Async};
use num_cpus;
use tokio_threadpool::*;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::{mpsc, Arc};
use test;
use tokio_threadpool::*;

#[bench]
fn spawn_many(b: &mut test::Bencher) {
Expand Down Expand Up @@ -97,7 +92,6 @@ mod cpupool {
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::{mpsc, Arc};
use test;

#[bench]
fn spawn_many(b: &mut test::Bencher) {
Expand Down
16 changes: 5 additions & 11 deletions tokio-threadpool/benches/blocking.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#![feature(test)]
#![deny(warnings)]
#![deny(warnings, rust_2018_idioms)]

extern crate futures;
extern crate rand;
extern crate test;
extern crate threadpool;
extern crate tokio_threadpool;

const ITER: usize = 1_000;

mod blocking {
use super::*;

use futures::future::*;
use tokio_threadpool::{blocking, Builder};

Expand All @@ -20,9 +15,9 @@ mod blocking {
let pool = Builder::new().pool_size(2).max_blocking(20).build();

b.iter(|| {
let count_down = Arc::new(CountDown::new(::ITER));
let count_down = Arc::new(CountDown::new(ITER));

for _ in 0..::ITER {
for _ in 0..ITER {
let count_down = count_down.clone();

pool.spawn(lazy(move || {
Expand All @@ -42,7 +37,6 @@ mod blocking {

mod message_passing {
use super::*;

use futures::future::*;
use futures::sync::oneshot;
use tokio_threadpool::Builder;
Expand All @@ -54,9 +48,9 @@ mod message_passing {
let blocking = threadpool::ThreadPool::new(20);

b.iter(|| {
let count_down = Arc::new(CountDown::new(::ITER));
let count_down = Arc::new(CountDown::new(ITER));

for _ in 0..::ITER {
for _ in 0..ITER {
let count_down = count_down.clone();
let blocking = blocking.clone();

Expand Down
8 changes: 1 addition & 7 deletions tokio-threadpool/benches/depth.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#![feature(test)]
#![deny(warnings)]
#![deny(warnings, rust_2018_idioms)]

extern crate futures;
extern crate futures_cpupool;
extern crate num_cpus;
extern crate test;
extern crate tokio_threadpool;

const ITER: usize = 20_000;

mod us {
use futures::future;
use std::sync::mpsc;
use test;
use tokio_threadpool::*;

#[bench]
Expand Down Expand Up @@ -47,7 +42,6 @@ mod cpupool {
use futures_cpupool::*;
use num_cpus;
use std::sync::mpsc;
use test;

#[bench]
fn chained_spawn(b: &mut test::Bencher) {
Expand Down
10 changes: 4 additions & 6 deletions tokio-threadpool/src/blocking.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use worker::Worker;

use futures::Poll;

use crate::worker::Worker;
use futures::{try_ready, Poll};
use std::error::Error;
use std::fmt;

Expand Down Expand Up @@ -157,13 +155,13 @@ where
}

impl fmt::Display for BlockingError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{}", self.description())
}
}

impl fmt::Debug for BlockingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BlockingError")
.field("reason", &self.description())
.finish()
Expand Down
31 changes: 15 additions & 16 deletions tokio-threadpool/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
use callback::Callback;
use config::{Config, MAX_WORKERS};
use park::{BoxPark, BoxedPark, DefaultPark};
use pool::{Pool, MAX_BACKUP};
use shutdown::ShutdownTrigger;
use thread_pool::ThreadPool;
use worker::{self, Worker, WorkerId};

use crate::callback::Callback;
use crate::config::{Config, MAX_WORKERS};
use crate::park::{BoxPark, BoxedPark, DefaultPark};
use crate::pool::{Pool, MAX_BACKUP};
use crate::shutdown::ShutdownTrigger;
use crate::thread_pool::ThreadPool;
use crate::worker::{self, Worker, WorkerId};
use crossbeam_deque::Injector;
use log::trace;
use num_cpus;
use tokio_executor::park::Park;
use tokio_executor::Enter;
use std::any::Any;
use std::cmp::max;
use std::error::Error;
use std::fmt;
use std::sync::Arc;
use std::time::Duration;

use crossbeam_deque::Injector;
use num_cpus;
use tokio_executor::park::Park;
use tokio_executor::Enter;

/// Builds a thread pool with custom configuration values.
///
/// Methods can be chained in order to set the configuration values. The thread
Expand Down Expand Up @@ -67,7 +66,7 @@ pub struct Builder {
max_blocking: usize,

/// Generates the `Park` instances
new_park: Box<Fn(&WorkerId) -> BoxPark>,
new_park: Box<dyn Fn(&WorkerId) -> BoxPark>,
}

impl Builder {
Expand Down Expand Up @@ -223,7 +222,7 @@ impl Builder {
/// ```
pub fn panic_handler<F>(&mut self, f: F) -> &mut Self
where
F: Fn(Box<Any + Send>) + Send + Sync + 'static,
F: Fn(Box<dyn Any + Send>) + Send + Sync + 'static,
{
self.config.panic_handler = Some(Arc::new(f));
self
Expand Down Expand Up @@ -466,7 +465,7 @@ impl Builder {
}

impl fmt::Debug for Builder {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Builder")
.field("config", &self.config)
.field("pool_size", &self.pool_size)
Expand Down
10 changes: 4 additions & 6 deletions tokio-threadpool/src/callback.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use worker::Worker;

use crate::worker::Worker;
use tokio_executor::Enter;
use std::fmt;
use std::sync::Arc;

use tokio_executor::Enter;

#[derive(Clone)]
pub(crate) struct Callback {
f: Arc<Fn(&Worker, &mut Enter) + Send + Sync>,
f: Arc<dyn Fn(&Worker, &mut Enter) + Send + Sync>,
}

impl Callback {
Expand All @@ -24,7 +22,7 @@ impl Callback {
}

impl fmt::Debug for Callback {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "Fn")
}
}
11 changes: 5 additions & 6 deletions tokio-threadpool/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use callback::Callback;

use crate::callback::Callback;
use std::any::Any;
use std::fmt;
use std::sync::Arc;
Expand All @@ -13,9 +12,9 @@ pub(crate) struct Config {
pub name_prefix: Option<String>,
pub stack_size: Option<usize>,
pub around_worker: Option<Callback>,
pub after_start: Option<Arc<Fn() + Send + Sync>>,
pub before_stop: Option<Arc<Fn() + Send + Sync>>,
pub panic_handler: Option<Arc<Fn(Box<Any + Send>) + Send + Sync>>,
pub after_start: Option<Arc<dyn Fn() + Send + Sync>>,
pub before_stop: Option<Arc<dyn Fn() + Send + Sync>>,
pub panic_handler: Option<Arc<dyn Fn(Box<dyn Any + Send>) + Send + Sync>>,
}

/// Max number of workers that can be part of a pool. This is the most that can
Expand All @@ -24,7 +23,7 @@ pub(crate) struct Config {
pub(crate) const MAX_WORKERS: usize = 1 << 15;

impl fmt::Debug for Config {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Config")
.field("keep_alive", &self.keep_alive)
.field("name_prefix", &self.name_prefix)
Expand Down
29 changes: 8 additions & 21 deletions tokio-threadpool/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![doc(html_root_url = "https://docs.rs/tokio-threadpool/0.1.14")]
#![deny(warnings, missing_docs, missing_debug_implementations)]
#![deny(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![cfg_attr(test, deny(warnings))]

//! A work-stealing based thread pool for executing futures.
//!
Expand Down Expand Up @@ -77,20 +78,6 @@
//! [`blocking`]: fn.blocking.html
//! [`runtime`]: https://docs.rs/tokio/0.1/tokio/runtime/

extern crate tokio_executor;

extern crate crossbeam_deque;
extern crate crossbeam_queue;
extern crate crossbeam_utils;
#[macro_use]
extern crate futures;
extern crate num_cpus;
extern crate rand;
extern crate slab;

#[macro_use]
extern crate log;

// ## Crate layout
//
// The primary type, `Pool`, holds the majority of a thread pool's state,
Expand Down Expand Up @@ -155,9 +142,9 @@ mod task;
mod thread_pool;
mod worker;

pub use blocking::{blocking, BlockingError};
pub use builder::Builder;
pub use sender::Sender;
pub use shutdown::Shutdown;
pub use thread_pool::{SpawnHandle, ThreadPool};
pub use worker::{Worker, WorkerId};
pub use crate::blocking::{blocking, BlockingError};
pub use crate::builder::Builder;
pub use crate::sender::Sender;
pub use crate::shutdown::Shutdown;
pub use crate::thread_pool::{SpawnHandle, ThreadPool};
pub use crate::worker::{Worker, WorkerId};
9 changes: 4 additions & 5 deletions tokio-threadpool/src/notifier.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use pool::Pool;
use task::Task;

use crate::pool::Pool;
use crate::task::Task;
use futures::executor::Notify;
use log::trace;
use std::mem;
use std::ops;
use std::sync::Arc;

use futures::executor::Notify;

/// Implements the future `Notify` API.
///
/// This is how external events are able to signal the task, informing it to try
Expand Down
6 changes: 3 additions & 3 deletions tokio-threadpool/src/park/boxed.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use log::warn;
use tokio_executor::park::{Park, Unpark};

use std::error::Error;
use std::time::Duration;

pub(crate) type BoxPark = Box<Park<Unpark = BoxUnpark, Error = ()> + Send>;
pub(crate) type BoxUnpark = Box<Unpark>;
pub(crate) type BoxPark = Box<dyn Park<Unpark = BoxUnpark, Error = ()> + Send>;
pub(crate) type BoxUnpark = Box<dyn Unpark>;

pub(crate) struct BoxedPark<T>(T);

Expand Down
6 changes: 2 additions & 4 deletions tokio-threadpool/src/park/default_park.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use tokio_executor::park::{Park, Unpark};

use crossbeam_utils::sync::{Parker, Unparker};
use std::error::Error;
use std::fmt;
use std::time::Duration;

use crossbeam_utils::sync::{Parker, Unparker};

/// Parks the thread.
#[derive(Debug)]
pub struct DefaultPark {
Expand Down Expand Up @@ -85,7 +83,7 @@ impl Unpark for DefaultUnpark {
// ===== impl ParkError =====

impl fmt::Display for ParkError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
self.description().fmt(fmt)
}
}
Expand Down
6 changes: 3 additions & 3 deletions tokio-threadpool/src/pool/backup.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use park::DefaultPark;
use worker::WorkerId;
use crate::park::DefaultPark;
use crate::worker::WorkerId;

use std::cell::UnsafeCell;
use std::fmt;
Expand Down Expand Up @@ -298,7 +298,7 @@ impl From<State> for usize {
}

impl fmt::Debug for State {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("backup::State")
.field("is_pushed", &self.is_pushed())
.field("is_running", &self.is_running())
Expand Down
2 changes: 1 addition & 1 deletion tokio-threadpool/src/pool/backup_stack.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pool::{Backup, BackupId};
use crate::pool::{Backup, BackupId};

use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::{AcqRel, Acquire};
Expand Down
Loading