File tree Expand file tree Collapse file tree 4 files changed +21
-35
lines changed Expand file tree Collapse file tree 4 files changed +21
-35
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ use crate::info;
22
22
use crate :: schedule:: BaseAction ;
23
23
use crate :: schedule:: delay_or_shutdown;
24
24
use crate :: schedule:: execute_or_shutdown;
25
- use crate :: schedule:: initial_delay_or_shutdown;
26
25
27
26
/// Repeatable action that can be scheduled with arbitrary delay.
28
27
///
@@ -54,8 +53,12 @@ pub trait ArbitraryDelayActionExt: ArbitraryDelayAction {
54
53
) ;
55
54
56
55
' schedule: {
57
- if initial_delay_or_shutdown ( & self , & make_delay, initial_delay) . await {
58
- break ' schedule;
56
+ if let Some ( initial_delay) = initial_delay {
57
+ if initial_delay > Duration :: ZERO
58
+ && delay_or_shutdown ( & mut self , make_delay. delay ( initial_delay) ) . await
59
+ {
60
+ break ' schedule;
61
+ }
59
62
}
60
63
61
64
loop {
@@ -66,7 +69,7 @@ pub trait ArbitraryDelayActionExt: ArbitraryDelayAction {
66
69
}
67
70
68
71
let next = self . next_run_at ( ) ;
69
- if delay_or_shutdown ( & self , make_delay. delay_util ( next) ) . await {
72
+ if delay_or_shutdown ( & mut self , make_delay. delay_util ( next) ) . await {
70
73
break ;
71
74
}
72
75
}
Original file line number Diff line number Diff line change 15
15
//! Repeatable and cancellable actions.
16
16
17
17
use std:: future:: Future ;
18
- use std:: time:: Duration ;
19
-
20
- use crate :: MakeDelay ;
21
18
22
19
use self :: select:: Either ;
23
20
use self :: select:: select;
@@ -51,28 +48,7 @@ pub trait BaseAction: Send + 'static {
51
48
}
52
49
53
50
/// Returns `true` if the action is shutdown.
54
- async fn initial_delay_or_shutdown < A , D > (
55
- action : & A ,
56
- make_delay : & D ,
57
- initial_delay : Option < Duration > ,
58
- ) -> bool
59
- where
60
- A : BaseAction ,
61
- D : MakeDelay ,
62
- {
63
- let Some ( initial_delay) = initial_delay else {
64
- return false ;
65
- } ;
66
-
67
- if initial_delay. is_zero ( ) {
68
- return false ;
69
- }
70
-
71
- delay_or_shutdown ( action, make_delay. delay ( initial_delay) ) . await
72
- }
73
-
74
- /// Returns `true` if the action is shutdown.
75
- async fn delay_or_shutdown < A , D > ( action : & A , delay : D ) -> bool
51
+ async fn delay_or_shutdown < A , D > ( action : & mut A , delay : D ) -> bool
76
52
where
77
53
A : BaseAction ,
78
54
D : Future < Output = ( ) > ,
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ use crate::Spawn;
20
20
use crate :: debug;
21
21
use crate :: info;
22
22
use crate :: schedule:: BaseAction ;
23
+ use crate :: schedule:: delay_or_shutdown;
23
24
use crate :: schedule:: execute_or_shutdown;
24
- use crate :: schedule:: initial_delay_or_shutdown;
25
25
26
26
/// Repeatable action that can be scheduled by notifications.
27
27
///
@@ -63,8 +63,12 @@ pub trait NotifyActionExt: NotifyAction {
63
63
) ;
64
64
65
65
' schedule: {
66
- if initial_delay_or_shutdown ( & mut self , make_delay, initial_delay) . await {
67
- break ' schedule;
66
+ if let Some ( initial_delay) = initial_delay {
67
+ if initial_delay > Duration :: ZERO
68
+ && delay_or_shutdown ( & mut self , make_delay. delay ( initial_delay) ) . await
69
+ {
70
+ break ' schedule;
71
+ }
68
72
}
69
73
70
74
loop {
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ use crate::make_instant_from_now;
25
25
use crate :: schedule:: BaseAction ;
26
26
use crate :: schedule:: delay_or_shutdown;
27
27
use crate :: schedule:: execute_or_shutdown;
28
- use crate :: schedule:: initial_delay_or_shutdown;
29
28
30
29
/// Repeatable action.
31
30
///
@@ -59,8 +58,12 @@ pub trait SimpleActionExt: SimpleAction {
59
58
) ;
60
59
61
60
' schedule: {
62
- if initial_delay_or_shutdown ( & mut self , & make_delay, initial_delay) . await {
63
- break ' schedule;
61
+ if let Some ( initial_delay) = initial_delay {
62
+ if initial_delay > Duration :: ZERO
63
+ && delay_or_shutdown ( & mut self , make_delay. delay ( initial_delay) ) . await
64
+ {
65
+ break ' schedule;
66
+ }
64
67
}
65
68
66
69
loop {
You can’t perform that action at this time.
0 commit comments