mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
chore: enable full CI run (#1399)
* update all tests * fix doc examples * misc API tweaks
This commit is contained in:
@@ -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