File tree 2 files changed +25
-7
lines changed
2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change 431
431
//! number of permits, which tasks may request in order to enter a critical
432
432
//! section. Semaphores are useful for implementing limiting or bounding of
433
433
//! any kind.
434
+ //!
435
+ //! # Runtime compatibility
436
+ //!
437
+ //! All synchronization primitives provided in this module are runtime agnostic.
438
+ //! You can freely move them between different instances of the Tokio runtime
439
+ //! or even use them from non-Tokio runtimes.
440
+ //!
441
+ //! The only exception to this is the [`mpsc::Sender::send_timeout`] method.
442
+ //! It relies on functionality from the [`time`](crate::time) module which
443
+ //! does not allow you to call it from non-Tokio runtimes.
444
+ //! However, [`Senders`](mpsc::Sender) can still be moved between different
445
+ //! instances of the Tokio runtime without you losing the ability to call
446
+ //! `send_timeout` on them.
447
+ //!
448
+ //! When used in a Tokio runtime, the synchronization primitives in this module
449
+ //! participate in [cooperative scheduling](crate::task#cooperative-scheduling),
450
+ //! periodically yielding back control to the runtime to avoid starving it.
451
+ //! This is Tokio specific behaviour that does not come into effect when the
452
+ //! synchronization primitive is used in a non-Tokio runtime.
434
453
435
454
cfg_sync ! {
436
455
/// Named future types.
Original file line number Diff line number Diff line change 70
70
//!
71
71
//! # Multiple runtimes
72
72
//!
73
- //! The mpsc channel does not care about which runtime you use it in, and can be
74
- //! used to send messages from one runtime to another. It can also be used in
75
- //! non-Tokio runtimes.
76
- //!
77
- //! There is one exception to the above: the [`send_timeout`] must be used from
78
- //! within a Tokio runtime, however it is still not tied to one specific Tokio
79
- //! runtime, and the sender may be moved from one Tokio runtime to another.
73
+ //! The mpsc channel is runtime agnostic and can be used to send messages
74
+ //! between different runtimes, including non-Tokio runtimes.
75
+ //! The only exception being [`send_timeout`], which needs to be called from
76
+ //! a Tokio runtime.
77
+ //! For more details see
78
+ //! [the documentation of the `sync` module](crate::sync#runtime-compatibility).
80
79
//!
81
80
//! # Allocation behavior
82
81
//!
You can’t perform that action at this time.
0 commit comments