Skip to content

Commit ec77529

Browse files
authored
refactor: Rename delay_util to delay_until in MakeDelay trait (#29)
* refactor: Rename `delay_util` to `delay_until` in MakeDelay trait * test: update
1 parent c4461e1 commit ec77529

File tree

11 files changed

+19
-19
lines changed

11 files changed

+19
-19
lines changed

fastimer-driver/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl MakeFastimerDelay {
149149
impl MakeDelay for MakeFastimerDelay {
150150
type Delay = Delay;
151151

152-
fn delay_util(&self, at: Instant) -> Self::Delay {
152+
fn delay_until(&self, at: Instant) -> Self::Delay {
153153
self.0.delay_until(at)
154154
}
155155

fastimer-driver/tests/integration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use fastimer_driver::binary_heap_driver;
2121
#[track_caller]
2222
fn assert_duration_eq(actual: Duration, expected: Duration) {
2323
if expected.abs_diff(actual) > Duration::from_millis(250) {
24-
panic!("expected: {:?}, actual: {:?}", expected, actual);
24+
panic!("expected: {expected:?}, actual: {actual:?}");
2525
}
2626
}
2727

fastimer-tokio/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mod delay {
3434
impl MakeDelay for MakeTokioDelay {
3535
type Delay = tokio::time::Sleep;
3636

37-
fn delay_util(&self, at: Instant) -> Self::Delay {
37+
fn delay_until(&self, at: Instant) -> Self::Delay {
3838
tokio::time::sleep_until(tokio::time::Instant::from_std(at))
3939
}
4040

fastimer/src/interval.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use crate::far_future;
5555
/// struct TokioDelay;
5656
/// impl MakeDelay for TokioDelay {
5757
/// type Delay = tokio::time::Sleep;
58-
/// fn delay_util(&self, until: Instant) -> Self::Delay {
58+
/// fn delay_until(&self, until: Instant) -> Self::Delay {
5959
/// tokio::time::sleep_until(tokio::time::Instant::from_std(until))
6060
/// }
6161
/// }
@@ -91,7 +91,7 @@ use crate::far_future;
9191
/// struct TokioDelay;
9292
/// impl MakeDelay for TokioDelay {
9393
/// type Delay = tokio::time::Sleep;
94-
/// fn delay_util(&self, until: Instant) -> Self::Delay {
94+
/// fn delay_until(&self, until: Instant) -> Self::Delay {
9595
/// tokio::time::sleep_until(tokio::time::Instant::from_std(until))
9696
/// }
9797
/// }
@@ -145,7 +145,7 @@ pub fn interval<D: MakeDelay>(period: Duration, make_delay: D) -> Interval<D> {
145145
/// struct TokioDelay;
146146
/// impl MakeDelay for TokioDelay {
147147
/// type Delay = tokio::time::Sleep;
148-
/// fn delay_util(&self, until: Instant) -> Self::Delay {
148+
/// fn delay_until(&self, until: Instant) -> Self::Delay {
149149
/// tokio::time::sleep_until(tokio::time::Instant::from_std(until))
150150
/// }
151151
/// }
@@ -168,7 +168,7 @@ pub fn interval_at<D: MakeDelay>(start: Instant, period: Duration, make_delay: D
168168

169169
fn make_interval<D: MakeDelay>(start: Instant, period: Duration, make_delay: D) -> Interval<D> {
170170
let deadline = start;
171-
let delay = Box::pin(make_delay.delay_util(start));
171+
let delay = Box::pin(make_delay.delay_until(start));
172172
Interval {
173173
deadline,
174174
period,
@@ -267,7 +267,7 @@ impl<D: MakeDelay> Interval<D> {
267267
// When we arrive here, the internal delay returned `Poll::Ready`.
268268
// Reassign the delay but do not register it. It should be registered with
269269
// the next call to `poll_tick`.
270-
self.delay = Box::pin(self.make_delay.delay_util(next));
270+
self.delay = Box::pin(self.make_delay.delay_until(next));
271271

272272
// Return the time when we were scheduled to tick
273273
self.deadline = next;

fastimer/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ pub trait MakeDelay {
7878
type Delay: Future<Output = ()> + Send;
7979

8080
/// Create a future that completes at the specified instant.
81-
fn delay_util(&self, at: Instant) -> Self::Delay;
81+
fn delay_until(&self, at: Instant) -> Self::Delay;
8282

8383
/// Create a future that completes after the specified duration.
8484
fn delay(&self, duration: Duration) -> Self::Delay {
85-
self.delay_util(make_instant_from_now(duration))
85+
self.delay_until(make_instant_from_now(duration))
8686
}
8787
}
8888

fastimer/src/schedule/arbitrary.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub trait ArbitraryDelayActionExt: ArbitraryDelayAction {
8080
ControlFlow::Break(()) => break,
8181
};
8282

83-
if execute_or_shutdown(make_delay.delay_util(next), &mut is_shutdown)
83+
if execute_or_shutdown(make_delay.delay_until(next), &mut is_shutdown)
8484
.await
8585
.is_break()
8686
{

fastimer/src/schedule/simple.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub trait SimpleActionExt: SimpleAction {
166166
if let Some(initial_delay) = initial_delay {
167167
if initial_delay > Duration::ZERO {
168168
next = make_instant_from_now(initial_delay);
169-
if execute_or_shutdown(make_delay.delay_util(next), &mut is_shutdown)
169+
if execute_or_shutdown(make_delay.delay_until(next), &mut is_shutdown)
170170
.await
171171
.is_break()
172172
{
@@ -185,7 +185,7 @@ pub trait SimpleActionExt: SimpleAction {
185185
};
186186

187187
next = calculate_next_on_miss(next, period);
188-
if execute_or_shutdown(make_delay.delay_util(next), &mut is_shutdown)
188+
if execute_or_shutdown(make_delay.delay_until(next), &mut is_shutdown)
189189
.await
190190
.is_break()
191191
{

fastimer/src/timeout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ where
106106
F: IntoFuture,
107107
D: MakeDelay + ?Sized,
108108
{
109-
let delay = make_delay.delay_util(deadline);
109+
let delay = make_delay.delay_until(deadline);
110110
Timeout {
111111
value: future.into_future(),
112112
delay,

fastimer/tests/common/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct MakeTokioDelay;
2424
impl MakeDelay for MakeTokioDelay {
2525
type Delay = tokio::time::Sleep;
2626

27-
fn delay_util(&self, at: Instant) -> Self::Delay {
27+
fn delay_until(&self, at: Instant) -> Self::Delay {
2828
tokio::time::sleep_until(tokio::time::Instant::from_std(at))
2929
}
3030

fastimer/tests/interval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod common;
2424
#[track_caller]
2525
fn assert_duration_eq(actual: Duration, expected: Duration) {
2626
if expected.abs_diff(actual) > Duration::from_millis(250) {
27-
panic!("expected: {:?}, actual: {:?}", expected, actual);
27+
panic!("expected: {expected:?}, actual: {actual:?}");
2828
}
2929
}
3030

fastimer/tests/schedule.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ async fn test_simple_action() {
5858
let shutdown = Instant::now() + Duration::from_secs(10);
5959

6060
MySimpleAction::new("schedule_with_fixed_delay").schedule_with_fixed_delay(
61-
MakeTokioDelay.delay_util(shutdown),
61+
MakeTokioDelay.delay_until(shutdown),
6262
&TokioSpawn,
6363
MakeTokioDelay,
6464
initial_delay,
6565
Duration::from_secs(2),
6666
);
6767

6868
MySimpleAction::new("schedule_at_fixed_rate").schedule_at_fixed_rate(
69-
MakeTokioDelay.delay_util(shutdown),
69+
MakeTokioDelay.delay_until(shutdown),
7070
&TokioSpawn,
7171
MakeTokioDelay,
7272
initial_delay,
7373
Duration::from_secs(2),
7474
);
7575

7676
MakeTokioDelay
77-
.delay_util(shutdown + Duration::from_secs(1))
77+
.delay_until(shutdown + Duration::from_secs(1))
7878
.await;
7979
}

0 commit comments

Comments
 (0)