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> {
83
83
self . pollfd . fd = fd. as_fd ( ) . as_raw_fd ( ) as LibcFd ;
84
84
}
85
85
86
+ /// Clears the ready events.
87
+ #[ inline]
88
+ pub fn clear_revents ( & mut self ) {
89
+ self . pollfd . revents = 0 ;
90
+ }
91
+
86
92
/// Constructs a new `PollFd` holding `fd` and `events`.
87
93
///
88
94
/// 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> {
56
56
self . fd = fd. as_fd ( ) ;
57
57
}
58
58
59
+ /// Clears the ready events.
60
+ #[ inline]
61
+ pub fn clear_revents ( & mut self ) {
62
+ self . revents = 0 ;
63
+ }
64
+
59
65
/// Constructs a new `PollFd` holding `fd` and `events`.
60
66
///
61
67
/// 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() {
28
28
assert_eq ! ( poll_fds[ 0 ] . revents( ) , PollFlags :: IN ) ;
29
29
assert_eq ! ( poll_fds[ 0 ] . as_fd( ) . as_raw_fd( ) , reader. as_fd( ) . as_raw_fd( ) ) ;
30
30
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
+
31
36
// Read the byte from the pipe.
32
37
let mut buf = [ b'\0' ] ;
33
38
assert_eq ! ( with_retrying( || read( & reader, & mut buf) ) . unwrap( ) , 1 ) ;
You can’t perform that action at this time.
0 commit comments