File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ impl<'fd> PollFd<'fd> {
8383 self . pollfd . fd = fd. as_fd ( ) . as_raw_fd ( ) as LibcFd ;
8484 }
8585
86+ /// Clears the ready events.
87+ #[ inline]
88+ pub fn clear_revents ( & mut self ) {
89+ self . pollfd . revents = 0 ;
90+ }
91+
8692 /// Constructs a new `PollFd` holding `fd` and `events`.
8793 ///
8894 /// This is the same as `new`, but can be used to avoid borrowing the
Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ impl<'fd> PollFd<'fd> {
5656 self . fd = fd. as_fd ( ) ;
5757 }
5858
59+ /// Clears the ready events.
60+ #[ inline]
61+ pub fn clear_revents ( & mut self ) {
62+ self . revents = 0 ;
63+ }
64+
5965 /// Constructs a new `PollFd` holding `fd` and `events`.
6066 ///
6167 /// This is the same as `new`, but can be used to avoid borrowing the
Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ fn test_poll() {
2828 assert_eq ! ( poll_fds[ 0 ] . revents( ) , PollFlags :: IN ) ;
2929 assert_eq ! ( poll_fds[ 0 ] . as_fd( ) . as_raw_fd( ) , reader. as_fd( ) . as_raw_fd( ) ) ;
3030
31+ let mut temp = poll_fds[ 0 ] . clone ( ) ;
32+ assert_eq ! ( temp. revents( ) , PollFlags :: IN ) ;
33+ temp. clear_revents ( ) ;
34+ assert ! ( temp. revents( ) . is_empty( ) ) ;
35+
3136 // Read the byte from the pipe.
3237 let mut buf = [ b'\0' ] ;
3338 assert_eq ! ( with_retrying( || read( & reader, & mut buf) ) . unwrap( ) , 1 ) ;
You can’t perform that action at this time.
0 commit comments