5
5
6
6
use std:: fmt;
7
7
use std:: future:: Future ;
8
- use std:: io;
9
8
use std:: pin:: Pin ;
10
9
use std:: sync:: atomic:: AtomicUsize ;
11
10
use std:: sync:: atomic:: Ordering :: SeqCst ;
@@ -126,19 +125,16 @@ impl Delay {
126
125
}
127
126
128
127
impl Future for Delay {
129
- type Output = io :: Result < ( ) > ;
128
+ type Output = ( ) ;
130
129
131
130
fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
132
131
let state = match self . state {
133
132
Some ( ref state) => state,
134
- None => {
135
- let err = Err ( io:: Error :: new ( io:: ErrorKind :: Other , "timer has gone away" ) ) ;
136
- return Poll :: Ready ( err) ;
137
- }
133
+ None => panic ! ( "timer has gone away" ) ,
138
134
} ;
139
135
140
136
if state. state . load ( SeqCst ) & 1 != 0 {
141
- return Poll :: Ready ( Ok ( ( ) ) ) ;
137
+ return Poll :: Ready ( ( ) ) ;
142
138
}
143
139
144
140
state. waker . register ( & cx. waker ( ) ) ;
@@ -147,11 +143,8 @@ impl Future for Delay {
147
143
// state. If we've fired the first bit is set, and if we've been
148
144
// invalidated the second bit is set.
149
145
match state. state . load ( SeqCst ) {
150
- n if n & 0b01 != 0 => Poll :: Ready ( Ok ( ( ) ) ) ,
151
- n if n & 0b10 != 0 => Poll :: Ready ( Err ( io:: Error :: new (
152
- io:: ErrorKind :: Other ,
153
- "timer has gone away" ,
154
- ) ) ) ,
146
+ n if n & 0b01 != 0 => Poll :: Ready ( ( ) ) ,
147
+ n if n & 0b10 != 0 => panic ! ( "timer has gone away" ) ,
155
148
_ => Poll :: Pending ,
156
149
}
157
150
}
0 commit comments