File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -258,14 +258,19 @@ impl UpChannel {
258
258
Some ( UpChannel ( ptr) )
259
259
}
260
260
261
+ /// Returns true if the channel is empty.
262
+ pub fn is_empty ( & self ) -> bool {
263
+ let ( write, read) = self . channel ( ) . read_pointers ( ) ;
264
+ write == read
265
+ }
266
+
261
267
/// Wait until all data has been read by the debugger.
262
268
///
263
269
/// *Note: This means that if no debugger is connected or if it isn't reading the rtt data,*
264
270
/// *this function will wait indefinitely.*
265
271
pub fn flush ( & self ) {
266
272
loop {
267
- let ( write, read) = self . channel ( ) . read_pointers ( ) ;
268
- if write == read {
273
+ if self . is_empty ( ) {
269
274
break ;
270
275
}
271
276
core:: hint:: spin_loop ( ) ;
@@ -401,6 +406,19 @@ impl TerminalChannel {
401
406
pub fn set_mode ( & mut self , mode : ChannelMode ) {
402
407
self . channel . set_mode ( mode)
403
408
}
409
+
410
+ /// Returns true if the channel is empty.
411
+ pub fn is_empty ( & self ) -> bool {
412
+ self . channel . is_empty ( )
413
+ }
414
+
415
+ /// Wait until all data has been read by the debugger.
416
+ ///
417
+ /// *Note: This means that if no debugger is connected or if it isn't reading the rtt data,*
418
+ /// *this function will wait indefinitely.*
419
+ pub fn flush ( & self ) {
420
+ self . channel . flush ( ) ;
421
+ }
404
422
}
405
423
406
424
/// Formatted writing operation. Don't store an instance of this, but rather create a new one for
You can’t perform that action at this time.
0 commit comments