File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -697,14 +697,14 @@ impl<T> SyncSender<T> {
697
697
/// let sync_sender2 = sync_sender.clone();
698
698
///
699
699
/// // First thread owns sync_sender
700
- /// thread::spawn(move || {
700
+ /// let handle1 = thread::spawn(move || {
701
701
/// sync_sender.send(1).unwrap();
702
702
/// sync_sender.send(2).unwrap();
703
703
/// // Thread blocked
704
704
/// });
705
705
///
706
706
/// // Second thread owns sync_sender2
707
- /// thread::spawn(move || {
707
+ /// let handle2 = thread::spawn(move || {
708
708
/// // This will return an error and send
709
709
/// // no message if the buffer is full
710
710
/// let _ = sync_sender2.try_send(3);
@@ -722,6 +722,10 @@ impl<T> SyncSender<T> {
722
722
/// Ok(msg) => println!("message {msg} received"),
723
723
/// Err(_) => println!("the third message was never sent"),
724
724
/// }
725
+ ///
726
+ /// // Wait for threads to complete
727
+ /// handle1.join().unwrap();
728
+ /// handle2.join().unwrap();
725
729
/// ```
726
730
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
727
731
pub fn try_send ( & self , t : T ) -> Result < ( ) , TrySendError < T > > {
You can’t perform that action at this time.
0 commit comments