Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions library/std/src/sync/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,14 +697,14 @@ impl<T> SyncSender<T> {
/// let sync_sender2 = sync_sender.clone();
///
/// // First thread owns sync_sender
/// thread::spawn(move || {
/// let handle1 = thread::spawn(move || {
/// sync_sender.send(1).unwrap();
/// sync_sender.send(2).unwrap();
/// // Thread blocked
/// });
///
/// // Second thread owns sync_sender2
/// thread::spawn(move || {
/// let handle2 = thread::spawn(move || {
/// // This will return an error and send
/// // no message if the buffer is full
/// let _ = sync_sender2.try_send(3);
Expand All @@ -722,6 +722,10 @@ impl<T> SyncSender<T> {
/// Ok(msg) => println!("message {msg} received"),
/// Err(_) => println!("the third message was never sent"),
/// }
///
/// // Wait for threads to complete
/// handle1.join().unwrap();
/// handle2.join().unwrap();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn try_send(&self, t: T) -> Result<(), TrySendError<T>> {
Expand Down
Loading