Skip to content

Commit d1c6738

Browse files
yshuinotgull
authored andcommitted
Make Timer::clear public
Closes #238 Signed-off-by: Yuxuan Shui <[email protected]>
1 parent be049a8 commit d1c6738

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ impl Timer {
342342
None => {
343343
// Overflow to never going off.
344344
self.clear();
345-
self.when = None;
346345
}
347346
}
348347
}
@@ -405,7 +404,6 @@ impl Timer {
405404
None => {
406405
// Overflow to never going off.
407406
self.clear();
408-
self.when = None;
409407
}
410408
}
411409
}
@@ -443,12 +441,13 @@ impl Timer {
443441
}
444442
}
445443

446-
/// Helper function to clear the current timer.
447-
fn clear(&mut self) {
444+
/// Clear any timeouts set on this timer. It will never fire again until a new interval or instant is set.
445+
pub fn clear(&mut self) {
448446
if let (Some(when), Some((id, _))) = (self.when, self.id_and_waker.as_ref()) {
449447
// Deregister the timer from the reactor.
450448
Reactor::get().remove_timer(when, *id);
451449
}
450+
self.when = None;
452451
}
453452
}
454453

0 commit comments

Comments
 (0)