mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
docs: clarify CPU-bound tasks on Tokio (#4105)
This commit is contained in:
parent
33f0a1fd2e
commit
57563e218b
@ -205,9 +205,15 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! If your code is CPU-bound and you wish to limit the number of threads used
|
//! If your code is CPU-bound and you wish to limit the number of threads used
|
||||||
//! to run it, you should run it on another thread pool such as [rayon]. You
|
//! to run it, you should use a separate thread pool dedicated to CPU bound tasks.
|
||||||
//! can use an [`oneshot`] channel to send the result back to Tokio when the
|
//! For example, you could consider using the [rayon] library for CPU-bound
|
||||||
//! rayon task finishes.
|
//! tasks. It is also possible to create an extra Tokio runtime dedicated to
|
||||||
|
//! CPU-bound tasks, but if you do this, you should be careful that the extra
|
||||||
|
//! runtime runs _only_ CPU-bound tasks, as IO-bound tasks on that runtime
|
||||||
|
//! will behave poorly.
|
||||||
|
//!
|
||||||
|
//! Hint: If using rayon, you can use a [`oneshot`] channel to send the result back
|
||||||
|
//! to Tokio when the rayon task finishes.
|
||||||
//!
|
//!
|
||||||
//! [rayon]: https://docs.rs/rayon
|
//! [rayon]: https://docs.rs/rayon
|
||||||
//! [`oneshot`]: crate::sync::oneshot
|
//! [`oneshot`]: crate::sync::oneshot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user