Skip to content

Commit bddfff3

Browse files
committed
cleanup delay API
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
1 parent cae2aae commit bddfff3

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/delay.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,7 @@ impl Delay {
3838
/// The default timer will be spun up in a helper thread on first use.
3939
#[inline]
4040
pub fn new(dur: Duration) -> Delay {
41-
Delay::new_at(Instant::now() + dur)
42-
}
43-
44-
/// Creates a new future which will fire at the time specified by `at`.
45-
///
46-
/// The returned object will be bound to the default timer for this thread.
47-
/// The default timer will be spun up in a helper thread on first use.
48-
#[inline]
49-
pub fn new_at(at: Instant) -> Delay {
50-
Delay::new_handle(at, Default::default())
41+
Delay::new_handle(Instant::now() + dur, Default::default())
5142
}
5243

5344
/// Creates a new future which will fire at the time specified by `at`.
@@ -89,15 +80,6 @@ impl Delay {
8980
}
9081
}
9182

92-
/// Resets this timeout to an new timeout which will fire at the time
93-
/// specified by `dur`.
94-
///
95-
/// This is equivalent to calling `reset_at` with `Instant::now() + dur`
96-
#[inline]
97-
pub fn reset(&mut self, dur: Duration) {
98-
self.reset_at(Instant::now() + dur)
99-
}
100-
10183
/// Resets this timeout to an new timeout which will fire at the time
10284
/// specified by `at`.
10385
///
@@ -112,9 +94,9 @@ impl Delay {
11294
/// will be dropped. It is required to call `poll` again after this method
11395
/// has been called to ensure tha ta task is blocked on this future.
11496
#[inline]
115-
pub fn reset_at(&mut self, at: Instant) {
116-
self.when = at;
117-
if self._reset(at).is_err() {
97+
pub fn reset(&mut self, dur: Duration) {
98+
self.when = Instant::now() + dur;
99+
if self._reset(self.when).is_err() {
118100
self.state = None
119101
}
120102
}

0 commit comments

Comments
 (0)