|
32 | 32 | //! single producer to a single consumer. This channel is usually used to send
|
33 | 33 | //! the result of a computation to a waiter.
|
34 | 34 | //!
|
35 |
| -//! **Example:** using a `oneshot` channel to receive the result of a |
| 35 | +//! **Example:** using a [`oneshot` channel][oneshot] to receive the result of a |
36 | 36 | //! computation.
|
37 | 37 | //!
|
38 | 38 | //! ```
|
|
232 | 232 | //!
|
233 | 233 | //! ## `broadcast` channel
|
234 | 234 | //!
|
235 |
| -//! The [`broadcast` channel][broadcast] supports sending **many** values from |
| 235 | +//! The [`broadcast` channel] supports sending **many** values from |
236 | 236 | //! **many** producers to **many** consumers. Each consumer will receive
|
237 | 237 | //! **each** value. This channel can be used to implement "fan out" style
|
238 | 238 | //! patterns common with pub / sub or "chat" systems.
|
|
265 | 265 | //! }
|
266 | 266 | //! ```
|
267 | 267 | //!
|
| 268 | +//! [`broadcast` channel]: crate::sync::broadcast |
| 269 | +//! |
268 | 270 | //! ## `watch` channel
|
269 | 271 | //!
|
270 |
| -//! The [`watch` channel][watch] supports sending **many** values from a |
271 |
| -//! **single** producer to **many** consumers. However, only the **most recent** |
272 |
| -//! value is stored in the channel. Consumers are notified when a new value is |
273 |
| -//! sent, but there is no guarantee that consumers will see **all** values. |
| 272 | +//! The [`watch` channel] supports sending **many** values from a **single** |
| 273 | +//! producer to **many** consumers. However, only the **most recent** value is |
| 274 | +//! stored in the channel. Consumers are notified when a new value is sent, but |
| 275 | +//! there is no guarantee that consumers will see **all** values. |
274 | 276 | //!
|
275 | 277 | //! The [`watch` channel] is similar to a [`broadcast` channel] with capacity 1.
|
276 | 278 | //!
|
277 | 279 | //! Use cases for the [`watch` channel] include broadcasting configuration
|
278 | 280 | //! changes or signalling program state changes, such as transitioning to
|
279 | 281 | //! shutdown.
|
280 | 282 | //!
|
281 |
| -//! **Example:** use a `watch` channel to notify tasks of configuration changes. |
282 |
| -//! In this example, a configuration file is checked periodically. When the file |
283 |
| -//! changes, the configuration changes are signalled to consumers. |
| 283 | +//! **Example:** use a [`watch` channel] to notify tasks of configuration |
| 284 | +//! changes. In this example, a configuration file is checked periodically. When |
| 285 | +//! the file changes, the configuration changes are signalled to consumers. |
284 | 286 | //!
|
285 | 287 | //! ```
|
286 | 288 | //! use tokio::sync::watch;
|
|
393 | 395 | //! }
|
394 | 396 | //! ```
|
395 | 397 | //!
|
| 398 | +//! [`watch` channel]: crate::sync::watch |
| 399 | +//! [`broadcast` channel]: crate::sync::broadcast |
| 400 | +//! |
396 | 401 | //! # State synchronization
|
397 | 402 | //!
|
398 | 403 | //! The remaining synchronization primitives focus on synchronizing state.
|
|
0 commit comments