File tree 1 file changed +16
-15
lines changed
1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -83,21 +83,22 @@ struct Inner<T> {
83
83
/// ```
84
84
/// use futures::channel::oneshot;
85
85
/// use std::{thread, time::Duration};
86
- ///
87
- /// fn main() {
88
- /// let (sender, receiver) = oneshot::channel::<i32>();
89
- ///
90
- /// thread::spawn(|| {
91
- /// println!("THREAD: sleeping zzz...");
92
- /// thread::sleep(Duration::from_millis(2000));
93
- /// println!("THREAD: i'm awake! sending.");
94
- /// sender.send(3).unwrap();
95
- /// });
96
- ///
97
- /// println!("MAIN: doing some useful stuff; and waiting...");
98
- ///
99
- /// println!("MAIN: got: {:?}", futures::executor::block_on(receiver));
100
- /// }
86
+ ///
87
+ /// let (sender, receiver) = oneshot::channel::<i32>();
88
+ ///
89
+ /// thread::spawn(|| {
90
+ /// println!("THREAD: sleeping zzz...");
91
+ /// thread::sleep(Duration::from_millis(1000));
92
+ /// println!("THREAD: i'm awake! sending.");
93
+ /// sender.send(3).unwrap();
94
+ /// });
95
+ ///
96
+ /// println!("MAIN: doing some useful stuff");
97
+ ///
98
+ /// futures::executor::block_on(async {
99
+ /// println!("MAIN: waiting for msg...");
100
+ /// println!("MAIN: got: {:?}", receiver.await)
101
+ /// });
101
102
/// ```
102
103
pub fn channel < T > ( ) -> ( Sender < T > , Receiver < T > ) {
103
104
let inner = Arc :: new ( Inner :: new ( ) ) ;
You can’t perform that action at this time.
0 commit comments