diff options
Diffstat (limited to 'src/sync/parker.rs')
-rw-r--r-- | src/sync/parker.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sync/parker.rs b/src/sync/parker.rs index e791c44..9cb3a26 100644 --- a/src/sync/parker.rs +++ b/src/sync/parker.rs @@ -122,7 +122,10 @@ impl Parker { /// p.park_timeout(Duration::from_millis(500)); /// ``` pub fn park_timeout(&self, timeout: Duration) { - self.park_deadline(Instant::now() + timeout) + match Instant::now().checked_add(timeout) { + Some(deadline) => self.park_deadline(deadline), + None => self.park(), + } } /// Blocks the current thread until the token is made available, or until a certain deadline. |