Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc comments #2572

Merged
merged 2 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tokio/src/future/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

/// Future for the [`ready`](ready()) function.
/// Future for the [`ok`](ok()) function.
///
/// `pub` in order to use the future as an associated type in a sealed trait.
#[derive(Debug)]
Expand Down
3 changes: 2 additions & 1 deletion tokio/src/io/util/flush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::task::{Context, Poll};
cfg_io_util! {
/// A future used to fully flush an I/O object.
///
/// Created by the [`AsyncWriteExt::flush`] function.
/// Created by the [`AsyncWriteExt::flush`][flush] function.
/// [flush]: crate::io::AsyncWriteExt::flush
#[derive(Debug)]
pub struct Flush<'a, A: ?Sized> {
a: &'a mut A,
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/util/read_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ where
}

cfg_io_util! {
/// Future returned by [`read_buf`](AsyncReadExt::read_buf).
/// Future returned by [`read_buf`](crate::io::AsyncReadExt::read_buf).
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct ReadBuf<'a, R, B> {
Expand Down
3 changes: 2 additions & 1 deletion tokio/src/io/util/read_exact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use std::task::{Context, Poll};
/// A future which can be used to easily read exactly enough bytes to fill
/// a buffer.
///
/// Created by the [`AsyncRead::read_exact`].
/// Created by the [`AsyncReadExt::read_exact`][read_exact].
/// [read_exact]: [crate::io::AsyncReadExt::read_exact]
pub(crate) fn read_exact<'a, A>(reader: &'a mut A, buf: &'a mut [u8]) -> ReadExact<'a, A>
where
A: AsyncRead + Unpin + ?Sized,
Expand Down
3 changes: 2 additions & 1 deletion tokio/src/io/util/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::task::{Context, Poll};
cfg_io_util! {
/// A future used to shutdown an I/O object.
///
/// Created by the [`AsyncWriteExt::shutdown`] function.
/// Created by the [`AsyncWriteExt::shutdown`][shutdown] function.
/// [shutdown]: crate::io::AsyncWriteExt::shutdown
#[derive(Debug)]
pub struct Shutdown<'a, A: ?Sized> {
a: &'a mut A,
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/runtime/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ cfg_rt_core! {
}
}

/// Set this [`ThreadContext`] as the current active [`ThreadContext`].
/// Set this [`Handle`] as the current active [`Handle`].
///
/// [`ThreadContext`]: struct@ThreadContext
/// [`Handle`]: Handle
pub(crate) fn enter<F, R>(new: Handle, f: F) -> R
where
F: FnOnce() -> R,
Expand Down
27 changes: 16 additions & 11 deletions tokio/src/time/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ use std::sync::Arc;
use std::usize;
use std::{cmp, fmt};

/// Time implementation that drives [`Delay`], [`Interval`], and [`Timeout`].
/// Time implementation that drives [`Delay`][delay], [`Interval`][interval], and [`Timeout`][timeout].
///
/// A `Driver` instance tracks the state necessary for managing time and
/// notifying the [`Delay`] instances once their deadlines are reached.
/// notifying the [`Delay`][delay] instances once their deadlines are reached.
///
/// It is expected that a single instance manages many individual [`Delay`]
/// It is expected that a single instance manages many individual [`Delay`][delay]
/// instances. The `Driver` implementation is thread-safe and, as such, is able
/// to handle callers from across threads.
///
/// After creating the `Driver` instance, the caller must repeatedly call
/// [`turn`]. The time driver will perform no work unless [`turn`] is called
/// repeatedly.
/// After creating the `Driver` instance, the caller must repeatedly call `park`
/// or `park_timeout`. The time driver will perform no work unless `park` or
/// `park_timeout` is called repeatedly.
///
/// The driver has a resolution of one millisecond. Any unit of time that falls
/// between milliseconds are rounded up to the next millisecond.
///
/// When an instance is dropped, any outstanding [`Delay`] instance that has not
/// When an instance is dropped, any outstanding [`Delay`][delay] instance that has not
/// elapsed will be notified with an error. At this point, calling `poll` on the
/// [`Delay`] instance will result in `Err` being returned.
/// [`Delay`][delay] instance will result in panic.
///
/// # Implementation
///
/// THe time driver is based on the [paper by Varghese and Lauck][paper].
/// The time driver is based on the [paper by Varghese and Lauck][paper].
///
/// A hashed timing wheel is a vector of slots, where each slot handles a time
/// slice. As time progresses, the timer walks over the slot for the current
Expand All @@ -73,9 +73,14 @@ use std::{cmp, fmt};
/// When the timer processes entries at level zero, it will notify all the
/// `Delay` instances as their deadlines have been reached. For all higher
/// levels, all entries will be redistributed across the wheel at the next level
/// down. Eventually, as time progresses, entries will [`Delay`] instances will
/// down. Eventually, as time progresses, entries will [`Delay`][delay] instances will
/// either be canceled (dropped) or their associated entries will reach level
/// zero and be notified.
///
/// [paper]: http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf
/// [delay]: crate::time::Delay
/// [timeout]: crate::time::Timeout
/// [interval]: crate::time::Interval
#[derive(Debug)]
pub(crate) struct Driver<T> {
/// Shared state
Expand Down Expand Up @@ -119,7 +124,7 @@ where
T: Park,
{
/// Creates a new `Driver` instance that uses `park` to block the current
/// thread and `now` to get the current `Instant`.
/// thread and `clock` to get the current `Instant`.
///
/// Specifying the source of time is useful when testing.
pub(crate) fn new(park: T, clock: Clock) -> Driver<T> {
Expand Down