mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
chore: deny warnings for doc tests (#1539)
This commit is contained in:
parent
e2161502ad
commit
d1f60ac4c6
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Asynchronous stream of bytes.
|
//! Asynchronous stream of bytes.
|
||||||
//!
|
//!
|
||||||
|
@ -315,7 +315,6 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! # use tokio_io::AsyncWrite;
|
//! # use tokio_io::AsyncWrite;
|
||||||
//! # use tokio_codec::LengthDelimitedCodec;
|
//! # use tokio_codec::LengthDelimitedCodec;
|
||||||
//! # use bytes::BytesMut;
|
|
||||||
//! # fn write_frame<T: AsyncWrite>(io: T) {
|
//! # fn write_frame<T: AsyncWrite>(io: T) {
|
||||||
//! # let _ =
|
//! # let _ =
|
||||||
//! LengthDelimitedCodec::builder()
|
//! LengthDelimitedCodec::builder()
|
||||||
@ -842,7 +841,6 @@ impl Builder {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use tokio_io::AsyncRead;
|
|
||||||
/// use tokio_codec::LengthDelimitedCodec;
|
/// use tokio_codec::LengthDelimitedCodec;
|
||||||
/// # pub fn main() {
|
/// # pub fn main() {
|
||||||
/// LengthDelimitedCodec::builder()
|
/// LengthDelimitedCodec::builder()
|
||||||
@ -892,7 +890,6 @@ impl Builder {
|
|||||||
/// ```
|
/// ```
|
||||||
/// # use tokio_io::AsyncWrite;
|
/// # use tokio_io::AsyncWrite;
|
||||||
/// # use tokio_codec::LengthDelimitedCodec;
|
/// # use tokio_codec::LengthDelimitedCodec;
|
||||||
/// # use bytes::BytesMut;
|
|
||||||
/// # fn write_frame<T: AsyncWrite>(io: T) {
|
/// # fn write_frame<T: AsyncWrite>(io: T) {
|
||||||
/// LengthDelimitedCodec::builder()
|
/// LengthDelimitedCodec::builder()
|
||||||
/// .length_field_length(2)
|
/// .length_field_length(2)
|
||||||
@ -914,7 +911,6 @@ impl Builder {
|
|||||||
/// ```
|
/// ```
|
||||||
/// # use tokio_io::{AsyncRead, AsyncWrite};
|
/// # use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
/// # use tokio_codec::LengthDelimitedCodec;
|
/// # use tokio_codec::LengthDelimitedCodec;
|
||||||
/// # use bytes::BytesMut;
|
|
||||||
/// # fn write_frame<T: AsyncRead + AsyncWrite>(io: T) {
|
/// # fn write_frame<T: AsyncRead + AsyncWrite>(io: T) {
|
||||||
/// # let _ =
|
/// # let _ =
|
||||||
/// LengthDelimitedCodec::builder()
|
/// LengthDelimitedCodec::builder()
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Utilities for encoding and decoding frames.
|
//! Utilities for encoding and decoding frames.
|
||||||
//!
|
//!
|
||||||
|
@ -149,7 +149,7 @@ impl dyn Executor {
|
|||||||
/// println!("running on the executor");
|
/// println!("running on the executor");
|
||||||
/// })).unwrap();
|
/// })).unwrap();
|
||||||
///
|
///
|
||||||
/// handle.map(|_| println!("the future has completed"));
|
/// let handle = handle.map(|_| println!("the future has completed"));
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn spawn_with_handle<Fut>(
|
pub fn spawn_with_handle<Fut>(
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Task execution related traits and utilities.
|
//! Task execution related traits and utilities.
|
||||||
//!
|
//!
|
||||||
|
@ -104,7 +104,7 @@ pub struct BlockingError {
|
|||||||
/// // from the context of a `Future` implementation. Since we don't
|
/// // from the context of a `Future` implementation. Since we don't
|
||||||
/// // have a complicated requirement, we can use `poll_fn` in this
|
/// // have a complicated requirement, we can use `poll_fn` in this
|
||||||
/// // case.
|
/// // case.
|
||||||
/// poll_fn(move |_| {
|
/// let _ = poll_fn(move |_| {
|
||||||
/// blocking(|| {
|
/// blocking(|| {
|
||||||
/// let msg = rx.recv().unwrap();
|
/// let msg = rx.recv().unwrap();
|
||||||
/// println!("message = {}", msg);
|
/// println!("message = {}", msg);
|
||||||
|
@ -63,7 +63,7 @@ use crate::SpawnError;
|
|||||||
/// if item.is_none() { break; }
|
/// if item.is_none() { break; }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// self.tx.take().unwrap().send(()).map_err(|_| ());
|
/// let _ = self.tx.take().unwrap().send(()).map_err(|_| ());
|
||||||
/// Poll::Ready(())
|
/// Poll::Ready(())
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Asynchronous file and standard stream adaptation.
|
//! Asynchronous file and standard stream adaptation.
|
||||||
//!
|
//!
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Core I/O traits and combinators when working with Tokio.
|
//! Core I/O traits and combinators when working with Tokio.
|
||||||
//!
|
//!
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Macros for use with Tokio
|
//! Macros for use with Tokio
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! use tokio::net::TcpStream;
|
//! use tokio::net::TcpStream;
|
||||||
//!
|
//!
|
||||||
//! # async fn process<T>(t: T) {}
|
//! # async fn process<T>(_t: T) {}
|
||||||
//! # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
//! # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let stream = TcpStream::connect("93.184.216.34:9243").await?;
|
//! let stream = TcpStream::connect("93.184.216.34:9243").await?;
|
||||||
//!
|
//!
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Event loop that drives Tokio I/O resources.
|
//! Event loop that drives Tokio I/O resources.
|
||||||
//!
|
//!
|
||||||
|
@ -25,7 +25,7 @@ use std::task::{Context, Poll};
|
|||||||
/// use tokio::net::TcpListener;
|
/// use tokio::net::TcpListener;
|
||||||
///
|
///
|
||||||
/// use std::io;
|
/// use std::io;
|
||||||
/// # async fn process_socket<T>(socket: T) {}
|
/// # async fn process_socket<T>(_socket: T) {}
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() -> io::Result<()> {
|
/// async fn main() -> io::Result<()> {
|
||||||
@ -33,7 +33,7 @@ use std::task::{Context, Poll};
|
|||||||
///
|
///
|
||||||
/// loop {
|
/// loop {
|
||||||
/// let (socket, _) = listener.accept().await?;
|
/// let (socket, _) = listener.accept().await?;
|
||||||
/// process_socket(socket);
|
/// process_socket(socket).await;
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
@ -70,6 +70,7 @@ impl TcpListener {
|
|||||||
///
|
///
|
||||||
/// // use the listener
|
/// // use the listener
|
||||||
///
|
///
|
||||||
|
/// # let _ = listener;
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
@ -197,6 +198,7 @@ impl TcpListener {
|
|||||||
///
|
///
|
||||||
/// let std_listener = StdTcpListener::bind("127.0.0.1:0")?;
|
/// let std_listener = StdTcpListener::bind("127.0.0.1:0")?;
|
||||||
/// let listener = TcpListener::from_std(std_listener, &Handle::default())?;
|
/// let listener = TcpListener::from_std(std_listener, &Handle::default())?;
|
||||||
|
/// # let _ = listener;
|
||||||
/// # Ok::<_, Box<dyn std::error::Error>>(())
|
/// # Ok::<_, Box<dyn std::error::Error>>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn from_std(listener: net::TcpListener, handle: &Handle) -> io::Result<TcpListener> {
|
pub fn from_std(listener: net::TcpListener, handle: &Handle) -> io::Result<TcpListener> {
|
||||||
|
@ -270,14 +270,13 @@ impl TcpStream {
|
|||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use tokio::net::TcpStream;
|
/// use tokio::net::TcpStream;
|
||||||
/// use tokio::prelude::*;
|
|
||||||
/// use std::error::Error;
|
/// use std::error::Error;
|
||||||
/// use std::net::Shutdown;
|
/// use std::net::Shutdown;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() -> Result<(), Box<dyn Error>> {
|
/// async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
/// // Connect to a peer
|
/// // Connect to a peer
|
||||||
/// let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
|
/// let stream = TcpStream::connect("127.0.0.1:8080").await?;
|
||||||
///
|
///
|
||||||
/// // Shutdown the stream
|
/// // Shutdown the stream
|
||||||
/// stream.shutdown(Shutdown::Write)?;
|
/// stream.shutdown(Shutdown::Write)?;
|
||||||
|
@ -76,7 +76,7 @@ use std::task::{Context, Poll};
|
|||||||
/// match self.poll_evented.get_ref().accept() {
|
/// match self.poll_evented.get_ref().accept() {
|
||||||
/// Ok((socket, _)) => Poll::Ready(Ok(socket)),
|
/// Ok((socket, _)) => Poll::Ready(Ok(socket)),
|
||||||
/// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
|
/// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
|
||||||
/// self.poll_evented.clear_read_ready(cx, ready);
|
/// self.poll_evented.clear_read_ready(cx, ready)?;
|
||||||
/// Poll::Pending
|
/// Poll::Pending
|
||||||
/// }
|
/// }
|
||||||
/// Err(e) => Poll::Ready(Err(e)),
|
/// Err(e) => Poll::Ready(Err(e)),
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Asynchronous synchronization primitives.
|
//! Asynchronous synchronization primitives.
|
||||||
//!
|
//!
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
//! use tokio::sync::watch;
|
//! use tokio::sync::watch;
|
||||||
//!
|
//!
|
||||||
//! # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
//! # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let (mut tx, mut rx) = watch::channel("hello");
|
//! let (tx, mut rx) = watch::channel("hello");
|
||||||
//!
|
//!
|
||||||
//! tokio::spawn(async move {
|
//! tokio::spawn(async move {
|
||||||
//! while let Some(value) = rx.recv().await {
|
//! while let Some(value) = rx.recv().await {
|
||||||
@ -172,7 +172,7 @@ const CLOSED: usize = 1;
|
|||||||
/// use tokio::sync::watch;
|
/// use tokio::sync::watch;
|
||||||
///
|
///
|
||||||
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let (mut tx, mut rx) = watch::channel("hello");
|
/// let (tx, mut rx) = watch::channel("hello");
|
||||||
///
|
///
|
||||||
/// tokio::spawn(async move {
|
/// tokio::spawn(async move {
|
||||||
/// while let Some(value) = rx.recv().await {
|
/// while let Some(value) = rx.recv().await {
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Tokio and Futures based testing utilites
|
//! Tokio and Futures based testing utilites
|
||||||
|
|
||||||
|
@ -134,7 +134,6 @@ macro_rules! assert_ready_err {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::future::Future;
|
/// use std::future::Future;
|
||||||
/// use std::task::Poll;
|
|
||||||
/// use futures_util::{future, pin_mut};
|
/// use futures_util::{future, pin_mut};
|
||||||
/// use tokio_test::{assert_pending, task};
|
/// use tokio_test::{assert_pending, task};
|
||||||
///
|
///
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Utilities for tracking time.
|
//! Utilities for tracking time.
|
||||||
//!
|
//!
|
||||||
|
@ -38,7 +38,7 @@ use std::time::{Duration, Instant};
|
|||||||
/// use std::thread;
|
/// use std::thread;
|
||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
///
|
///
|
||||||
/// # async fn dox() {
|
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let (mut tx, rx) = mpsc::unbounded_channel();
|
/// let (mut tx, rx) = mpsc::unbounded_channel();
|
||||||
///
|
///
|
||||||
/// thread::spawn(move || {
|
/// thread::spawn(move || {
|
||||||
@ -54,7 +54,8 @@ use std::time::{Duration, Instant};
|
|||||||
/// });
|
/// });
|
||||||
///
|
///
|
||||||
/// // Wrap the future with a `Timeout` set to expire in 10 milliseconds.
|
/// // Wrap the future with a `Timeout` set to expire in 10 milliseconds.
|
||||||
/// process.timeout(Duration::from_millis(10)).await;
|
/// process.timeout(Duration::from_millis(10)).await?;
|
||||||
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -99,13 +100,14 @@ impl<T> Timeout<T> {
|
|||||||
///
|
///
|
||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
///
|
///
|
||||||
/// # async fn dox() {
|
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let (tx, rx) = oneshot::channel();
|
/// let (tx, rx) = oneshot::channel();
|
||||||
/// # tx.send(()).unwrap();
|
/// # tx.send(()).unwrap();
|
||||||
///
|
///
|
||||||
/// // Wrap the future with a `Timeout` set to expire in 10 milliseconds.
|
/// // Wrap the future with a `Timeout` set to expire in 10 milliseconds.
|
||||||
/// Timeout::new(rx, Duration::from_millis(10)).await;
|
/// Timeout::new(rx, Duration::from_millis(10)).await??;
|
||||||
/// }
|
/// # Ok(())
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new(value: T, timeout: Duration) -> Timeout<T> {
|
pub fn new(value: T, timeout: Duration) -> Timeout<T> {
|
||||||
let delay = Delay::new_timeout(now() + timeout, timeout);
|
let delay = Delay::new_timeout(now() + timeout, timeout);
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! Async TLS streams
|
//! Async TLS streams
|
||||||
//!
|
//!
|
||||||
|
@ -71,7 +71,7 @@ pub struct Spawn(());
|
|||||||
/// ```
|
/// ```
|
||||||
/// use tokio::net::TcpListener;
|
/// use tokio::net::TcpListener;
|
||||||
///
|
///
|
||||||
/// # async fn process<T>(t: T) {}
|
/// # async fn process<T>(_t: T) {}
|
||||||
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
/// # async fn dox() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut listener = TcpListener::bind("127.0.0.1:8080").await?;
|
/// let mut listener = TcpListener::bind("127.0.0.1:8080").await?;
|
||||||
///
|
///
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
unreachable_pub
|
unreachable_pub
|
||||||
)]
|
)]
|
||||||
#![deny(intra_doc_link_resolution_failure)]
|
#![deny(intra_doc_link_resolution_failure)]
|
||||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
#![doc(test(
|
||||||
|
no_crate_inject,
|
||||||
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
|
))]
|
||||||
|
|
||||||
//! A runtime for writing reliable, asynchronous, and slim applications.
|
//! A runtime for writing reliable, asynchronous, and slim applications.
|
||||||
//!
|
//!
|
||||||
|
@ -25,14 +25,13 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use tokio::runtime::current_thread::Runtime;
|
//! use tokio::runtime::current_thread::Runtime;
|
||||||
//! use tokio::prelude::*;
|
|
||||||
//! use std::thread;
|
//! use std::thread;
|
||||||
//!
|
//!
|
||||||
//! let mut runtime = Runtime::new().unwrap();
|
//! let runtime = Runtime::new().unwrap();
|
||||||
//! let handle = runtime.handle();
|
//! let handle = runtime.handle();
|
||||||
//!
|
//!
|
||||||
//! thread::spawn(move || {
|
//! thread::spawn(move || {
|
||||||
//! handle.spawn(async {
|
//! let _ = handle.spawn(async {
|
||||||
//! println!("hello world");
|
//! println!("hello world");
|
||||||
//! });
|
//! });
|
||||||
//! }).join().unwrap();
|
//! }).join().unwrap();
|
||||||
@ -45,9 +44,8 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use tokio::runtime::current_thread::Runtime;
|
//! use tokio::runtime::current_thread::Runtime;
|
||||||
//! use tokio::prelude::*;
|
|
||||||
//!
|
//!
|
||||||
//! let mut runtime = Runtime::new().unwrap();
|
//! let runtime = Runtime::new().unwrap();
|
||||||
//!
|
//!
|
||||||
//! // Use the runtime...
|
//! // Use the runtime...
|
||||||
//! // runtime.block_on(f); // where f is a future
|
//! // runtime.block_on(f); // where f is a future
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
//!
|
//!
|
||||||
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
|
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! // Create the runtime
|
//! // Create the runtime
|
||||||
//! let mut rt = Runtime::new()?;
|
//! let rt = Runtime::new()?;
|
||||||
//!
|
//!
|
||||||
//! // Spawn the root task
|
//! // Spawn the root task
|
||||||
//! rt.block_on(async {
|
//! rt.block_on(async {
|
||||||
|
@ -35,7 +35,7 @@ use std::any::Any;
|
|||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// // build Runtime
|
/// // build Runtime
|
||||||
/// let mut runtime = Builder::new()
|
/// let runtime = Builder::new()
|
||||||
/// .blocking_threads(4)
|
/// .blocking_threads(4)
|
||||||
/// .clock(Clock::system())
|
/// .clock(Clock::system())
|
||||||
/// .core_threads(4)
|
/// .core_threads(4)
|
||||||
@ -99,7 +99,7 @@ impl Builder {
|
|||||||
/// # use tokio::runtime;
|
/// # use tokio::runtime;
|
||||||
///
|
///
|
||||||
/// # pub fn main() {
|
/// # pub fn main() {
|
||||||
/// let mut rt = runtime::Builder::new()
|
/// let rt = runtime::Builder::new()
|
||||||
/// .panic_handler(|err| std::panic::resume_unwind(err))
|
/// .panic_handler(|err| std::panic::resume_unwind(err))
|
||||||
/// .build()
|
/// .build()
|
||||||
/// .unwrap();
|
/// .unwrap();
|
||||||
@ -127,7 +127,7 @@ impl Builder {
|
|||||||
/// # use tokio::runtime;
|
/// # use tokio::runtime;
|
||||||
///
|
///
|
||||||
/// # pub fn main() {
|
/// # pub fn main() {
|
||||||
/// let mut rt = runtime::Builder::new()
|
/// let rt = runtime::Builder::new()
|
||||||
/// .core_threads(4)
|
/// .core_threads(4)
|
||||||
/// .build()
|
/// .build()
|
||||||
/// .unwrap();
|
/// .unwrap();
|
||||||
@ -157,7 +157,7 @@ impl Builder {
|
|||||||
/// # use tokio::runtime;
|
/// # use tokio::runtime;
|
||||||
///
|
///
|
||||||
/// # pub fn main() {
|
/// # pub fn main() {
|
||||||
/// let mut rt = runtime::Builder::new()
|
/// let rt = runtime::Builder::new()
|
||||||
/// .blocking_threads(200)
|
/// .blocking_threads(200)
|
||||||
/// .build();
|
/// .build();
|
||||||
/// # }
|
/// # }
|
||||||
@ -186,7 +186,7 @@ impl Builder {
|
|||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
///
|
///
|
||||||
/// # pub fn main() {
|
/// # pub fn main() {
|
||||||
/// let mut rt = runtime::Builder::new()
|
/// let rt = runtime::Builder::new()
|
||||||
/// .keep_alive(Some(Duration::from_secs(30)))
|
/// .keep_alive(Some(Duration::from_secs(30)))
|
||||||
/// .build();
|
/// .build();
|
||||||
/// # }
|
/// # }
|
||||||
@ -210,7 +210,7 @@ impl Builder {
|
|||||||
/// # use tokio::runtime;
|
/// # use tokio::runtime;
|
||||||
///
|
///
|
||||||
/// # pub fn main() {
|
/// # pub fn main() {
|
||||||
/// let mut rt = runtime::Builder::new()
|
/// let rt = runtime::Builder::new()
|
||||||
/// .name_prefix("my-pool-")
|
/// .name_prefix("my-pool-")
|
||||||
/// .build();
|
/// .build();
|
||||||
/// # }
|
/// # }
|
||||||
@ -234,7 +234,7 @@ impl Builder {
|
|||||||
/// # use tokio::runtime;
|
/// # use tokio::runtime;
|
||||||
///
|
///
|
||||||
/// # pub fn main() {
|
/// # pub fn main() {
|
||||||
/// let mut rt = runtime::Builder::new()
|
/// let rt = runtime::Builder::new()
|
||||||
/// .stack_size(32 * 1024)
|
/// .stack_size(32 * 1024)
|
||||||
/// .build();
|
/// .build();
|
||||||
/// # }
|
/// # }
|
||||||
|
@ -75,7 +75,6 @@ impl Runtime {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use tokio::runtime::Runtime;
|
/// use tokio::runtime::Runtime;
|
||||||
/// use tokio::prelude::*;
|
|
||||||
///
|
///
|
||||||
/// let rt = Runtime::new()
|
/// let rt = Runtime::new()
|
||||||
/// .unwrap();
|
/// .unwrap();
|
||||||
@ -198,7 +197,6 @@ impl Runtime {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use tokio::runtime::Runtime;
|
/// use tokio::runtime::Runtime;
|
||||||
/// use tokio::prelude::*;
|
|
||||||
///
|
///
|
||||||
/// let rt = Runtime::new()
|
/// let rt = Runtime::new()
|
||||||
/// .unwrap();
|
/// .unwrap();
|
||||||
@ -239,7 +237,6 @@ impl Runtime {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use tokio::runtime::Runtime;
|
/// use tokio::runtime::Runtime;
|
||||||
/// use tokio::prelude::*;
|
|
||||||
///
|
///
|
||||||
/// let rt = Runtime::new()
|
/// let rt = Runtime::new()
|
||||||
/// .unwrap();
|
/// .unwrap();
|
||||||
|
@ -33,7 +33,7 @@ impl TaskExecutor {
|
|||||||
///
|
///
|
||||||
/// # fn dox() {
|
/// # fn dox() {
|
||||||
/// // Create the runtime
|
/// // Create the runtime
|
||||||
/// let mut rt = Runtime::new().unwrap();
|
/// let rt = Runtime::new().unwrap();
|
||||||
/// let executor = rt.executor();
|
/// let executor = rt.executor();
|
||||||
///
|
///
|
||||||
/// // Spawn a future onto the runtime
|
/// // Spawn a future onto the runtime
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
//! Wait 100ms and print "Hello World!"
|
//! Wait 100ms and print "Hello World!"
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use tokio::prelude::*;
|
|
||||||
//! use tokio::timer::delay;
|
//! use tokio::timer::delay;
|
||||||
//!
|
//!
|
||||||
//! use std::time::{Duration, Instant};
|
//! use std::time::Duration;
|
||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
//! #[tokio::main]
|
//! #[tokio::main]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user