mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
chore: enable full CI run (#1399)
* update all tests * fix doc examples * misc API tweaks
This commit is contained in:
@@ -41,4 +41,3 @@ rand = "0.7"
|
||||
env_logger = "0.5"
|
||||
tokio = { version = "0.2.0", path = "../tokio" }
|
||||
tokio-test = { version = "0.2.0", path = "../tokio-test" }
|
||||
futures-util-preview = "= 0.3.0-alpha.17"
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#![cfg(features = "broken")]
|
||||
|
||||
extern crate env_logger;
|
||||
extern crate futures;
|
||||
extern crate tokio_threadpool;
|
||||
|
||||
use futures::future::{self, Executor};
|
||||
use tokio_threadpool::*;
|
||||
|
||||
use std::sync::mpsc;
|
||||
|
||||
const ITER: usize = 2_000_000;
|
||||
// const ITER: usize = 30;
|
||||
|
||||
fn chained_spawn() {
|
||||
let pool = ThreadPool::new();
|
||||
let tx = pool.sender().clone();
|
||||
|
||||
fn spawn(tx: Sender, res_tx: mpsc::Sender<()>, n: usize) {
|
||||
if n == 0 {
|
||||
res_tx.send(()).unwrap();
|
||||
} else {
|
||||
let tx2 = tx.clone();
|
||||
tx.execute(future::lazy(move || {
|
||||
spawn(tx2, res_tx, n - 1);
|
||||
Ok(())
|
||||
}))
|
||||
.ok()
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
let (res_tx, res_rx) = mpsc::channel();
|
||||
|
||||
for _ in 0..10 {
|
||||
spawn(tx.clone(), res_tx.clone(), ITER);
|
||||
}
|
||||
|
||||
for _ in 0..10 {
|
||||
res_rx.recv().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let _ = ::env_logger::init();
|
||||
chained_spawn();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#![cfg(features = "broken")]
|
||||
|
||||
extern crate env_logger;
|
||||
extern crate futures;
|
||||
extern crate tokio_threadpool;
|
||||
|
||||
use futures::sync::oneshot;
|
||||
use futures::*;
|
||||
use tokio_threadpool::*;
|
||||
|
||||
pub fn main() {
|
||||
let _ = ::env_logger::init();
|
||||
|
||||
let pool = ThreadPool::new();
|
||||
let tx = pool.sender().clone();
|
||||
|
||||
let res = oneshot::spawn(
|
||||
future::lazy(|| {
|
||||
println!("Running on the pool");
|
||||
Ok::<_, ()>("complete")
|
||||
}),
|
||||
&tx,
|
||||
);
|
||||
|
||||
println!("Result: {:?}", res.wait());
|
||||
}
|
||||
@@ -80,11 +80,11 @@ pub struct BlockingError {
|
||||
/// that needs to be performed.
|
||||
///
|
||||
/// ```rust
|
||||
/// #![feature(async_await)]
|
||||
///
|
||||
/// use tokio_threadpool::{ThreadPool, blocking};
|
||||
///
|
||||
/// use futures::Future;
|
||||
/// use futures::future::{lazy, poll_fn};
|
||||
///
|
||||
/// use futures_util::future::poll_fn;
|
||||
/// use std::sync::mpsc;
|
||||
/// use std::thread;
|
||||
/// use std::time::Duration;
|
||||
@@ -101,21 +101,21 @@ pub struct BlockingError {
|
||||
///
|
||||
/// let pool = ThreadPool::new();
|
||||
///
|
||||
/// pool.spawn(lazy(move || {
|
||||
/// pool.spawn(async move {
|
||||
/// // Because `blocking` returns `Poll`, it is intended to be used
|
||||
/// // from the context of a `Future` implementation. Since we don't
|
||||
/// // have a complicated requirement, we can use `poll_fn` in this
|
||||
/// // case.
|
||||
/// poll_fn(move || {
|
||||
/// poll_fn(move |_| {
|
||||
/// blocking(|| {
|
||||
/// let msg = rx.recv().unwrap();
|
||||
/// println!("message = {}", msg);
|
||||
/// }).map_err(|_| panic!("the threadpool shut down"))
|
||||
/// })
|
||||
/// }));
|
||||
/// }).await;
|
||||
/// });
|
||||
///
|
||||
/// // Wait for the task we just spawned to complete.
|
||||
/// pool.shutdown_on_idle().wait().unwrap();
|
||||
/// pool.shutdown_on_idle().wait();
|
||||
/// }
|
||||
/// ```
|
||||
pub fn blocking<F, T>(f: F) -> Poll<Result<T, BlockingError>>
|
||||
|
||||
@@ -32,8 +32,10 @@ use tokio_executor::park::Park;
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(async_await)]
|
||||
///
|
||||
/// use tokio_threadpool::Builder;
|
||||
/// use futures::future::{Future, lazy};
|
||||
///
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let thread_pool = Builder::new()
|
||||
@@ -41,13 +43,12 @@ use tokio_executor::park::Park;
|
||||
/// .keep_alive(Some(Duration::from_secs(30)))
|
||||
/// .build();
|
||||
///
|
||||
/// thread_pool.spawn(lazy(|| {
|
||||
/// thread_pool.spawn(async {
|
||||
/// println!("called from a worker thread");
|
||||
/// Ok(())
|
||||
/// }));
|
||||
/// });
|
||||
///
|
||||
/// // Gracefully shutdown the threadpool
|
||||
/// thread_pool.shutdown().wait().unwrap();
|
||||
/// thread_pool.shutdown().wait();
|
||||
/// ```
|
||||
pub struct Builder {
|
||||
/// Thread pool specific configuration values
|
||||
|
||||
@@ -60,21 +60,19 @@ impl Sender {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use tokio_threadpool::ThreadPool;
|
||||
/// use futures::future::{Future, lazy};
|
||||
/// #![feature(async_await)]
|
||||
///
|
||||
/// use tokio_threadpool::ThreadPool;
|
||||
///
|
||||
/// # pub fn main() {
|
||||
/// // Create a thread pool with default configuration values
|
||||
/// let thread_pool = ThreadPool::new();
|
||||
///
|
||||
/// thread_pool.sender().spawn(lazy(|| {
|
||||
/// thread_pool.sender().spawn(async {
|
||||
/// println!("called from a worker thread");
|
||||
/// Ok(())
|
||||
/// })).unwrap();
|
||||
/// }).unwrap();
|
||||
///
|
||||
/// // Gracefully shutdown the threadpool
|
||||
/// thread_pool.shutdown().wait().unwrap();
|
||||
/// # }
|
||||
/// thread_pool.shutdown().wait();
|
||||
/// ```
|
||||
pub fn spawn<F>(&self, future: F) -> Result<(), SpawnError>
|
||||
where
|
||||
|
||||
@@ -51,19 +51,19 @@ impl ThreadPool {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use tokio_threadpool::ThreadPool;
|
||||
/// use futures::future::{Future, lazy};
|
||||
/// #![feature(async_await)]
|
||||
///
|
||||
/// use tokio_threadpool::ThreadPool;
|
||||
///
|
||||
/// // Create a thread pool with default configuration values
|
||||
/// let thread_pool = ThreadPool::new();
|
||||
///
|
||||
/// thread_pool.spawn(lazy(|| {
|
||||
/// thread_pool.spawn(async {
|
||||
/// println!("called from a worker thread");
|
||||
/// Ok(())
|
||||
/// }));
|
||||
/// });
|
||||
///
|
||||
/// // Gracefully shutdown the threadpool
|
||||
/// thread_pool.shutdown().wait().unwrap();
|
||||
/// thread_pool.shutdown().wait();
|
||||
/// ```
|
||||
///
|
||||
/// # Panics
|
||||
|
||||
Reference in New Issue
Block a user