File tree Expand file tree Collapse file tree 3 files changed +51
-5
lines changed Expand file tree Collapse file tree 3 files changed +51
-5
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ pub fn stderr() -> Stderr {
4444#[ derive( Debug ) ]
4545pub struct Stderr ( Mutex < State > ) ;
4646
47+ #[ derive( Debug ) ]
48+ pub struct StderrLock < ' a > ( std:: io:: StderrLock < ' a > ) ;
49+
50+ unsafe impl Send for StderrLock < ' _ > { }
51+
4752/// The state of the asynchronous stderr.
4853///
4954/// The stderr can be either idle or busy performing an asynchronous operation.
@@ -98,12 +103,12 @@ impl Stderr {
98103 /// #
99104 /// # Ok(()) }) }
100105 /// ```
101- pub async fn lock ( & self ) -> std :: io :: StderrLock < ' static > {
106+ pub async fn lock ( & self ) -> StderrLock < ' static > {
102107 lazy_static ! {
103108 static ref STDERR : std:: io:: Stderr = std:: io:: stderr( ) ;
104109 }
105110
106- STDERR . lock ( )
111+ blocking :: spawn ( move || StderrLock ( STDERR . lock ( ) ) ) . await
107112 }
108113}
109114
@@ -209,3 +214,21 @@ cfg_windows! {
209214 }
210215 }
211216}
217+
218+ impl Write for StderrLock < ' _ > {
219+ fn poll_write (
220+ self : Pin < & mut Self > ,
221+ _cx : & mut Context < ' _ > ,
222+ _buf : & [ u8 ] ,
223+ ) -> Poll < io:: Result < usize > > {
224+ unimplemented ! ( )
225+ }
226+
227+ fn poll_flush ( self : Pin < & mut Self > , _cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
228+ unimplemented ! ( )
229+ }
230+
231+ fn poll_close ( self : Pin < & mut Self > , _cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
232+ unimplemented ! ( )
233+ }
234+ }
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ impl Stdin {
165165 static ref STDIN : std:: io:: Stdin = std:: io:: stdin( ) ;
166166 }
167167
168- blocking:: spawn ( move || { StdinLock ( STDIN . lock ( ) ) } ) . await
168+ blocking:: spawn ( move || StdinLock ( STDIN . lock ( ) ) ) . await
169169 }
170170}
171171
Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ pub fn stdout() -> Stdout {
4444#[ derive( Debug ) ]
4545pub struct Stdout ( Mutex < State > ) ;
4646
47+ #[ derive( Debug ) ]
48+ pub struct StdoutLock < ' a > ( std:: io:: StdoutLock < ' a > ) ;
49+
50+ unsafe impl Send for StdoutLock < ' _ > { }
51+
4752/// The state of the asynchronous stdout.
4853///
4954/// The stdout can be either idle or busy performing an asynchronous operation.
@@ -98,12 +103,12 @@ impl Stdout {
98103 /// #
99104 /// # Ok(()) }) }
100105 /// ```
101- pub async fn lock ( & self ) -> std :: io :: StdoutLock < ' static > {
106+ pub async fn lock ( & self ) -> StdoutLock < ' static > {
102107 lazy_static ! {
103108 static ref STDOUT : std:: io:: Stdout = std:: io:: stdout( ) ;
104109 }
105110
106- STDOUT . lock ( )
111+ blocking :: spawn ( move || StdoutLock ( STDOUT . lock ( ) ) ) . await
107112 }
108113}
109114
@@ -209,3 +214,21 @@ cfg_windows! {
209214 }
210215 }
211216}
217+
218+ impl Write for StdoutLock < ' _ > {
219+ fn poll_write (
220+ self : Pin < & mut Self > ,
221+ _cx : & mut Context < ' _ > ,
222+ _buf : & [ u8 ] ,
223+ ) -> Poll < io:: Result < usize > > {
224+ unimplemented ! ( )
225+ }
226+
227+ fn poll_flush ( self : Pin < & mut Self > , _cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
228+ unimplemented ! ( )
229+ }
230+
231+ fn poll_close ( self : Pin < & mut Self > , _cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
232+ unimplemented ! ( )
233+ }
234+ }
You can’t perform that action at this time.
0 commit comments