-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
General rustdoc improvements #450
Changes from 8 commits
3c8fd7e
f38630b
70c6542
a0e4190
30e0034
234ba3c
9a6652b
311d7cc
a0880e0
ad04b61
250d0c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,79 +44,10 @@ | |
pub mod current_thread; | ||
|
||
#[deprecated(since = "0.1.8", note = "use tokio-threadpool crate instead")] | ||
#[doc(hidden)] | ||
/// Re-exports of [`tokio-threadpool`], deprecated in favor of the crate. | ||
/// | ||
/// [`tokio-threadpool`]: https://docs.rs/tokio-threadpool/0.1 | ||
pub mod thread_pool { | ||
//! Maintains a pool of threads across which the set of spawned tasks are | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this doc can probably be moved to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that some (but looking at specifics, not necessarily all) of the original remains useful and could be reused for tokio-threadpool. I will include that in update plan. |
||
//! executed. | ||
//! | ||
//! [`ThreadPool`] is an executor that uses a thread pool for executing | ||
//! tasks concurrently across multiple cores. It uses a thread pool that is | ||
//! optimized for use cases that involve multiplexing large number of | ||
//! independent tasks that perform short(ish) amounts of computation and are | ||
//! mainly waiting on I/O, i.e. the Tokio use case. | ||
//! | ||
//! Usually, users of [`ThreadPool`] will not create pool instances. | ||
//! Instead, they will create a [`Runtime`] instance, which comes with a | ||
//! pre-configured thread pool. | ||
//! | ||
//! At the core, [`ThreadPool`] uses a work-stealing based scheduling | ||
//! strategy. When spawning a task while *external* to the thread pool | ||
//! (i.e., from a thread that is not part of the thread pool), the task is | ||
//! randomly assigned to a worker thread. When spawning a task while | ||
//! *internal* to the thread pool, the task is assigned to the current | ||
//! worker. | ||
//! | ||
//! Each worker maintains its own queue and first focuses on processing all | ||
//! tasks in its queue. When the worker's queue is empty, the worker will | ||
//! attempt to *steal* tasks from other worker queues. This strategy helps | ||
//! ensure that work is evenly distributed across threads while minimizing | ||
//! synchronization between worker threads. | ||
//! | ||
//! # Usage | ||
//! | ||
//! Thread pool instances are created using [`ThreadPool::new`] or | ||
//! [`Builder::new`]. The first option returns a thread pool with default | ||
//! configuration values. The second option allows configuring the thread | ||
//! pool before instantiating it. | ||
//! | ||
//! Once an instance is obtained, futures may be spawned onto it using the | ||
//! [`spawn`] function. | ||
//! | ||
//! A handle to the thread pool is obtained using [`ThreadPool::sender`]. | ||
//! This handle is **only** able to spawn futures onto the thread pool. It | ||
//! is unable to affect the lifecycle of the thread pool in any way. This | ||
//! handle can be passed into functions or stored in structs as a way to | ||
//! grant the capability of spawning futures. | ||
//! | ||
//! # Examples | ||
//! | ||
//! ```rust | ||
//! # extern crate tokio; | ||
//! # extern crate futures; | ||
//! # use tokio::executor::thread_pool::ThreadPool; | ||
//! use futures::future::{Future, lazy}; | ||
//! | ||
//! # pub fn main() { | ||
//! // Create a thread pool with default configuration values | ||
//! let thread_pool = ThreadPool::new(); | ||
//! | ||
//! thread_pool.spawn(lazy(|| { | ||
//! println!("called from a worker thread"); | ||
//! Ok(()) | ||
//! })); | ||
//! | ||
//! // Gracefully shutdown the threadpool | ||
//! thread_pool.shutdown().wait().unwrap(); | ||
//! # } | ||
//! ``` | ||
//! | ||
//! [`ThreadPool`]: struct.ThreadPool.html | ||
//! [`ThreadPool::new`]: struct.ThreadPool.html#method.new | ||
//! [`ThreadPool::sender`]: struct.ThreadPool.html#method.sender | ||
//! [`spawn`]: struct.ThreadPool.html#method.spawn | ||
//! [`Builder::new`]: struct.Builder.html#method.new | ||
//! [`Runtime`]: ../../runtime/struct.Runtime.html | ||
|
||
pub use tokio_threadpool::{ | ||
Builder, | ||
Sender, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify why you removed
#[doc(hidden)]
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed
#[doc(hidden)]
so that the deprecation tag plus the short note and link I added to tokio-threadpool is visible. As of the last 0.1.7 release there was the full documentation here. Otherwise, on current master (without my change) the module just vanishes from the rustdoc, without even the deprecation tag being visible, which isn't super helpful to anyone currently using that path and wondering how to upgrade.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is the deprecation message would provide the upgrade hint. The pattern in the past is to hide deprecated APIs from docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrespective of conventions, my change improves the rustdoc by showing the deprecation and a link. The deprecation note is still useful/visible when compiling something that uses this path. Also I removed the much larger doc-comment section that would show up without the
doc(hidden)
, so that is also at parity.If you feel strongly that deprecated re-exports must not be documented (I respectfully disagree), then I can put the
#[doc(hidden)]
back and remove my new doc-comment and link.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way, it can be sorted later.