forked from ROMEO/nexosim
Overload schedule_*event
methods
The `schedule_*event_in` and `schedule_*event_at` pairs of methods are each merged into a single overloaded method accepting either a relative `Duration`or an absolute `MonotonicTime`.
This commit is contained in:
@ -15,7 +15,7 @@ fn model_schedule_event() {
|
||||
impl TestModel {
|
||||
fn trigger(&mut self, _: (), scheduler: &Scheduler<Self>) {
|
||||
scheduler
|
||||
.schedule_event_at(scheduler.time() + Duration::from_secs(2), Self::action, ())
|
||||
.schedule_event(scheduler.time() + Duration::from_secs(2), Self::action, ())
|
||||
.unwrap();
|
||||
}
|
||||
async fn action(&mut self) {
|
||||
@ -51,14 +51,10 @@ fn model_cancel_future_keyed_event() {
|
||||
impl TestModel {
|
||||
fn trigger(&mut self, _: (), scheduler: &Scheduler<Self>) {
|
||||
scheduler
|
||||
.schedule_event_at(scheduler.time() + Duration::from_secs(1), Self::action1, ())
|
||||
.schedule_event(scheduler.time() + Duration::from_secs(1), Self::action1, ())
|
||||
.unwrap();
|
||||
self.key = scheduler
|
||||
.schedule_keyed_event_at(
|
||||
scheduler.time() + Duration::from_secs(2),
|
||||
Self::action2,
|
||||
(),
|
||||
)
|
||||
.schedule_keyed_event(scheduler.time() + Duration::from_secs(2), Self::action2, ())
|
||||
.ok();
|
||||
}
|
||||
async fn action1(&mut self) {
|
||||
@ -100,14 +96,10 @@ fn model_cancel_same_time_keyed_event() {
|
||||
impl TestModel {
|
||||
fn trigger(&mut self, _: (), scheduler: &Scheduler<Self>) {
|
||||
scheduler
|
||||
.schedule_event_at(scheduler.time() + Duration::from_secs(2), Self::action1, ())
|
||||
.schedule_event(scheduler.time() + Duration::from_secs(2), Self::action1, ())
|
||||
.unwrap();
|
||||
self.key = scheduler
|
||||
.schedule_keyed_event_at(
|
||||
scheduler.time() + Duration::from_secs(2),
|
||||
Self::action2,
|
||||
(),
|
||||
)
|
||||
.schedule_keyed_event(scheduler.time() + Duration::from_secs(2), Self::action2, ())
|
||||
.ok();
|
||||
}
|
||||
async fn action1(&mut self) {
|
||||
@ -148,7 +140,7 @@ fn model_schedule_periodic_event() {
|
||||
impl TestModel {
|
||||
fn trigger(&mut self, _: (), scheduler: &Scheduler<Self>) {
|
||||
scheduler
|
||||
.schedule_periodic_event_at(
|
||||
.schedule_periodic_event(
|
||||
scheduler.time() + Duration::from_secs(2),
|
||||
Duration::from_secs(3),
|
||||
Self::action,
|
||||
@ -195,7 +187,7 @@ fn model_cancel_periodic_event() {
|
||||
impl TestModel {
|
||||
fn trigger(&mut self, _: (), scheduler: &Scheduler<Self>) {
|
||||
self.key = scheduler
|
||||
.schedule_periodic_keyed_event_at(
|
||||
.schedule_keyed_periodic_event(
|
||||
scheduler.time() + Duration::from_secs(2),
|
||||
Duration::from_secs(3),
|
||||
Self::action,
|
||||
|
@ -49,9 +49,9 @@ fn simulation_schedule_events() {
|
||||
let (mut simu, t0, addr, mut output) = simple_bench();
|
||||
|
||||
// Queue 2 events at t0+3s and t0+2s, in reverse order.
|
||||
simu.schedule_event_in(Duration::from_secs(3), PassThroughModel::input, (), &addr)
|
||||
simu.schedule_event(Duration::from_secs(3), PassThroughModel::input, (), &addr)
|
||||
.unwrap();
|
||||
simu.schedule_event_at(
|
||||
simu.schedule_event(
|
||||
t0 + Duration::from_secs(2),
|
||||
PassThroughModel::input,
|
||||
(),
|
||||
@ -65,7 +65,7 @@ fn simulation_schedule_events() {
|
||||
assert!(output.next().is_some());
|
||||
|
||||
// Schedule another event in 4s (at t0+6s).
|
||||
simu.schedule_event_in(Duration::from_secs(4), PassThroughModel::input, (), &addr)
|
||||
simu.schedule_event(Duration::from_secs(4), PassThroughModel::input, (), &addr)
|
||||
.unwrap();
|
||||
|
||||
// Move to the 2nd event at t0+3s.
|
||||
@ -85,7 +85,7 @@ fn simulation_schedule_keyed_events() {
|
||||
let (mut simu, t0, addr, mut output) = simple_bench();
|
||||
|
||||
let event_t1 = simu
|
||||
.schedule_keyed_event_at(
|
||||
.schedule_keyed_event(
|
||||
t0 + Duration::from_secs(1),
|
||||
PassThroughModel::input,
|
||||
1,
|
||||
@ -94,10 +94,10 @@ fn simulation_schedule_keyed_events() {
|
||||
.unwrap();
|
||||
|
||||
let event_t2_1 = simu
|
||||
.schedule_keyed_event_in(Duration::from_secs(2), PassThroughModel::input, 21, &addr)
|
||||
.schedule_keyed_event(Duration::from_secs(2), PassThroughModel::input, 21, &addr)
|
||||
.unwrap();
|
||||
|
||||
simu.schedule_event_in(Duration::from_secs(2), PassThroughModel::input, 22, &addr)
|
||||
simu.schedule_event(Duration::from_secs(2), PassThroughModel::input, 22, &addr)
|
||||
.unwrap();
|
||||
|
||||
// Move to the 1st event at t0+1.
|
||||
@ -123,7 +123,7 @@ fn simulation_schedule_periodic_events() {
|
||||
let (mut simu, t0, addr, mut output) = simple_bench();
|
||||
|
||||
// Queue 2 periodic events at t0 + 3s + k*2s.
|
||||
simu.schedule_periodic_event_in(
|
||||
simu.schedule_periodic_event(
|
||||
Duration::from_secs(3),
|
||||
Duration::from_secs(2),
|
||||
PassThroughModel::input,
|
||||
@ -131,7 +131,7 @@ fn simulation_schedule_periodic_events() {
|
||||
&addr,
|
||||
)
|
||||
.unwrap();
|
||||
simu.schedule_periodic_event_at(
|
||||
simu.schedule_periodic_event(
|
||||
t0 + Duration::from_secs(3),
|
||||
Duration::from_secs(2),
|
||||
PassThroughModel::input,
|
||||
@ -158,7 +158,7 @@ fn simulation_schedule_periodic_keyed_events() {
|
||||
let (mut simu, t0, addr, mut output) = simple_bench();
|
||||
|
||||
// Queue 2 periodic events at t0 + 3s + k*2s.
|
||||
simu.schedule_periodic_event_in(
|
||||
simu.schedule_periodic_event(
|
||||
Duration::from_secs(3),
|
||||
Duration::from_secs(2),
|
||||
PassThroughModel::input,
|
||||
@ -167,7 +167,7 @@ fn simulation_schedule_periodic_keyed_events() {
|
||||
)
|
||||
.unwrap();
|
||||
let event2_key = simu
|
||||
.schedule_periodic_keyed_event_at(
|
||||
.schedule_keyed_periodic_event(
|
||||
t0 + Duration::from_secs(3),
|
||||
Duration::from_secs(2),
|
||||
PassThroughModel::input,
|
||||
|
Reference in New Issue
Block a user