Update Tokio to Rust 2018 (#1082)

This commit is contained in:
Carl Lerche
2019-05-14 10:27:36 -07:00
committed by GitHub
parent 79d8820050
commit cb4aea394e
343 changed files with 1725 additions and 2813 deletions
+11 -14
View File
@@ -1,24 +1,21 @@
extern crate env_logger;
extern crate futures;
extern crate tokio_executor;
extern crate tokio_threadpool;
use tokio_executor::park::{Park, Unpark};
use tokio_threadpool::park::{DefaultPark, DefaultUnpark};
use tokio_threadpool::*;
#![deny(warnings, rust_2018_idioms)]
use futures::future::lazy;
use futures::{Async, Future, Poll, Sink, Stream};
use std::cell::Cell;
use std::sync::atomic::Ordering::Relaxed;
use std::sync::atomic::*;
use std::sync::{mpsc, Arc};
use std::time::Duration;
use tokio_executor::park::{Park, Unpark};
use tokio_threadpool::park::{DefaultPark, DefaultUnpark};
use tokio_threadpool::*;
thread_local!(static FOO: Cell<u32> = Cell::new(0));
fn ignore_results<F: Future + Send + 'static>(f: F) -> Box<Future<Item = (), Error = ()> + Send> {
fn ignore_results<F: Future + Send + 'static>(
f: F,
) -> Box<dyn Future<Item = (), Error = ()> + Send> {
Box::new(f.map(|_| ()).map_err(|_| ()))
}
@@ -129,7 +126,7 @@ fn force_shutdown_drops_futures() {
b.fetch_add(1, Relaxed);
})
.build();
let mut tx = pool.sender().clone();
let tx = pool.sender().clone();
tx.spawn(Never(num_drop.clone())).unwrap();
@@ -188,7 +185,7 @@ fn drop_threadpool_drops_futures() {
b.fetch_add(1, Relaxed);
})
.build();
let mut tx = pool.sender().clone();
let tx = pool.sender().clone();
tx.spawn(Never(num_drop.clone())).unwrap();
@@ -217,7 +214,7 @@ fn many_oneshot_futures() {
for _ in 0..50 {
let pool = ThreadPool::new();
let mut tx = pool.sender().clone();
let tx = pool.sender().clone();
let cnt = Arc::new(AtomicUsize::new(0));
for _ in 0..NUM {
@@ -249,7 +246,7 @@ fn many_multishot_futures() {
for _ in 0..50 {
let pool = ThreadPool::new();
let mut pool_tx = pool.sender().clone();
let pool_tx = pool.sender().clone();
let mut start_txs = Vec::with_capacity(TRACKS);
let mut final_rxs = Vec::with_capacity(TRACKS);