mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +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
|
||||
//! to run it, you should run it on another thread pool such as [rayon]. You
|
||||
//! can use an [`oneshot`] channel to send the result back to Tokio when the
|
||||
//! rayon task finishes.
|
||||
//! to run it, you should use a separate thread pool dedicated to CPU bound tasks.
|
||||
//! For example, you could consider using the [rayon] library for CPU-bound
|
||||
//! 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
|
||||
//! [`oneshot`]: crate::sync::oneshot
|
||||
|
Loading…
x
Reference in New Issue
Block a user