File tree 2 files changed +24
-7
lines changed
2 files changed +24
-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
+ //! When used in a Tokio runtime, the synchronization primitives participate in
442
+ //! [cooperative scheduling](crate::task#cooperative-scheduling),
443
+ //! periodically yielding back control to the runtime to avoid starving it.
444
+ //! In a non-Tokio runtime, the yield points where control is handed back do
445
+ //! nothing, not changing the behavior of the synchronization primitive in any
446
+ //! way.
447
+ //!
448
+ //! The only exception to runtime compatibility is the
449
+ //! [`mpsc::Sender::send_timeout`] method, which can't be called from non-Tokio
450
+ //! runtimes. However, [`Senders`](mpsc::Sender) can still be moved between
451
+ //! different instances of the Tokio runtime.
434
452
435
453
cfg_sync ! {
436
454
/// 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