@@ -120,7 +120,7 @@ impl Parker {
120120 /// // Waits for the token to become available, but will not wait longer than 500 ms.
121121 /// p.park_timeout(Duration::from_millis(500));
122122 /// ```
123- pub fn park_timeout ( & self , timeout : Duration ) -> UnparkReason {
123+ pub fn park_timeout ( & self , timeout : Duration ) {
124124 self . park_deadline ( Instant :: now ( ) + timeout)
125125 }
126126
@@ -138,7 +138,7 @@ impl Parker {
138138 /// // Waits for the token to become available, but will not wait longer than 500 ms.
139139 /// p.park_deadline(deadline);
140140 /// ```
141- pub fn park_deadline ( & self , deadline : Instant ) -> UnparkReason {
141+ pub fn park_deadline ( & self , deadline : Instant ) {
142142 self . unparker . inner . park ( Some ( deadline) )
143143 }
144144
@@ -301,18 +301,6 @@ impl Clone for Unparker {
301301 }
302302}
303303
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-
316304const EMPTY : usize = 0 ;
317305const PARKED : usize = 1 ;
318306const NOTIFIED : usize = 2 ;
@@ -324,20 +312,20 @@ struct Inner {
324312}
325313
326314impl Inner {
327- fn park ( & self , deadline : Option < Instant > ) -> UnparkReason {
315+ fn park ( & self , deadline : Option < Instant > ) {
328316 // If we were previously notified then we consume this notification and return quickly.
329317 if self
330318 . state
331319 . compare_exchange ( NOTIFIED , EMPTY , SeqCst , SeqCst )
332320 . is_ok ( )
333321 {
334- return UnparkReason :: Unparked ;
322+ return ;
335323 }
336324
337325 // If the timeout is zero, then there is no need to actually block.
338326 if let Some ( deadline) = deadline {
339327 if deadline <= Instant :: now ( ) {
340- return UnparkReason :: Timeout ;
328+ return ;
341329 }
342330 }
343331
@@ -355,7 +343,7 @@ impl Inner {
355343 // do that we must read from the write it made to `state`.
356344 let old = self . state . swap ( EMPTY , SeqCst ) ;
357345 assert_eq ! ( old, NOTIFIED , "park state changed unexpectedly" ) ;
358- return UnparkReason :: Unparked ;
346+ return ;
359347 }
360348 Err ( n) => panic ! ( "inconsistent park_timeout state: {}" , n) ,
361349 }
@@ -373,9 +361,8 @@ impl Inner {
373361 self . cvar . wait_timeout ( m, deadline - now) . unwrap ( ) . 0
374362 } else {
375363 // 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 ,
379366 n => panic ! ( "inconsistent park_timeout state: {}" , n) ,
380367 } ;
381368 }
@@ -388,7 +375,7 @@ impl Inner {
388375 . is_ok ( )
389376 {
390377 // got a notification
391- return UnparkReason :: Unparked ;
378+ return ;
392379 }
393380
394381 // Spurious wakeup, go back to sleep. Alternatively, if we timed out, it will be caught
0 commit comments