@@ -120,7 +120,7 @@ impl Parker {
120
120
/// // Waits for the token to become available, but will not wait longer than 500 ms.
121
121
/// p.park_timeout(Duration::from_millis(500));
122
122
/// ```
123
- pub fn park_timeout ( & self , timeout : Duration ) -> UnparkReason {
123
+ pub fn park_timeout ( & self , timeout : Duration ) {
124
124
self . park_deadline ( Instant :: now ( ) + timeout)
125
125
}
126
126
@@ -138,7 +138,7 @@ impl Parker {
138
138
/// // Waits for the token to become available, but will not wait longer than 500 ms.
139
139
/// p.park_deadline(deadline);
140
140
/// ```
141
- pub fn park_deadline ( & self , deadline : Instant ) -> UnparkReason {
141
+ pub fn park_deadline ( & self , deadline : Instant ) {
142
142
self . unparker . inner . park ( Some ( deadline) )
143
143
}
144
144
@@ -301,18 +301,6 @@ impl Clone for Unparker {
301
301
}
302
302
}
303
303
304
- /// An enum that reports whether a `Parker::park_timeout` or
305
- /// `Parker::park_deadline` returned because another thread called `unpark` or
306
- /// because of a timeout.
307
- #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
308
- pub enum UnparkReason {
309
- /// The park method returned due to a call to `unpark`.
310
- Unparked ,
311
-
312
- /// The park method returned due to a timeout.
313
- Timeout ,
314
- }
315
-
316
304
const EMPTY : usize = 0 ;
317
305
const PARKED : usize = 1 ;
318
306
const NOTIFIED : usize = 2 ;
@@ -324,20 +312,20 @@ struct Inner {
324
312
}
325
313
326
314
impl Inner {
327
- fn park ( & self , deadline : Option < Instant > ) -> UnparkReason {
315
+ fn park ( & self , deadline : Option < Instant > ) {
328
316
// If we were previously notified then we consume this notification and return quickly.
329
317
if self
330
318
. state
331
319
. compare_exchange ( NOTIFIED , EMPTY , SeqCst , SeqCst )
332
320
. is_ok ( )
333
321
{
334
- return UnparkReason :: Unparked ;
322
+ return ;
335
323
}
336
324
337
325
// If the timeout is zero, then there is no need to actually block.
338
326
if let Some ( deadline) = deadline {
339
327
if deadline <= Instant :: now ( ) {
340
- return UnparkReason :: Timeout ;
328
+ return ;
341
329
}
342
330
}
343
331
@@ -355,7 +343,7 @@ impl Inner {
355
343
// do that we must read from the write it made to `state`.
356
344
let old = self . state . swap ( EMPTY , SeqCst ) ;
357
345
assert_eq ! ( old, NOTIFIED , "park state changed unexpectedly" ) ;
358
- return UnparkReason :: Unparked ;
346
+ return ;
359
347
}
360
348
Err ( n) => panic ! ( "inconsistent park_timeout state: {}" , n) ,
361
349
}
@@ -373,9 +361,8 @@ impl Inner {
373
361
self . cvar . wait_timeout ( m, deadline - now) . unwrap ( ) . 0
374
362
} else {
375
363
// We've timed out; swap out the state back to empty on our way out
376
- return match self . state . swap ( EMPTY , SeqCst ) {
377
- NOTIFIED => UnparkReason :: Unparked , // got a notification
378
- PARKED => UnparkReason :: Timeout , // no notification
364
+ match self . state . swap ( EMPTY , SeqCst ) {
365
+ NOTIFIED | PARKED => return ,
379
366
n => panic ! ( "inconsistent park_timeout state: {}" , n) ,
380
367
} ;
381
368
}
@@ -388,7 +375,7 @@ impl Inner {
388
375
. is_ok ( )
389
376
{
390
377
// got a notification
391
- return UnparkReason :: Unparked ;
378
+ return ;
392
379
}
393
380
394
381
// Spurious wakeup, go back to sleep. Alternatively, if we timed out, it will be caught
0 commit comments