File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,29 @@ impl Timer {
277
277
}
278
278
}
279
279
280
+ /// Indicates whether or not this timer will ever fire.
281
+ ///
282
+ /// [`never()`] will never fire, and timers created with [`after()`] or [`at()`] will fire
283
+ /// if the duration is not too large.
284
+ ///
285
+ /// # Examples
286
+ ///
287
+ /// ```
288
+ /// use async_io::Timer;
289
+ /// use std::time::Duration;
290
+ ///
291
+ /// // `never` will never fire.
292
+ /// assert!(!Timer::never().will_fire());
293
+ ///
294
+ /// // `after` will fire if the duration is not too large.
295
+ /// assert!(Timer::after(Duration::from_secs(1)).will_fire());
296
+ /// assert!(!Timer::after(Duration::MAX).will_fire());
297
+ /// ```
298
+ #[ inline]
299
+ pub fn will_fire ( & self ) -> bool {
300
+ self . when . is_some ( )
301
+ }
302
+
280
303
/// Sets the timer to emit an en event once after the given duration of time.
281
304
///
282
305
/// Note that resetting a timer is different from creating a new timer because
You can’t perform that action at this time.
0 commit comments