chore: enable full CI run (#1399)

* update all tests
* fix doc examples
* misc API tweaks
This commit is contained in:
Carl Lerche
2019-08-07 20:02:13 -07:00
committed by GitHub
parent 831be9c08e
commit 962521f449
53 changed files with 1231 additions and 2793 deletions
+8 -8
View File
@@ -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>>
+6 -5
View File
@@ -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
+6 -8
View File
@@ -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
+6 -6
View File
@@ -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