|
|
|
@ -36,7 +36,7 @@ impl SectionRunnerInner {
@@ -36,7 +36,7 @@ impl SectionRunnerInner {
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
|
enum RunnerMsg { |
|
|
|
|
Quit, |
|
|
|
|
Quit(oneshot::Sender<()>), |
|
|
|
|
QueueRun(SectionRunHandle, SectionRef, Duration), |
|
|
|
|
CancelRun(SectionRunHandle), |
|
|
|
|
CancelAll, |
|
|
|
@ -112,6 +112,7 @@ struct RunnerTask {
@@ -112,6 +112,7 @@ struct RunnerTask {
|
|
|
|
|
delay_future: OptionFuture<tokio::time::Delay>, |
|
|
|
|
paused: bool, |
|
|
|
|
event_send: Option<SectionEventSend>, |
|
|
|
|
quit_tx: Option<oneshot::Sender<()>>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl RunnerTask { |
|
|
|
@ -126,6 +127,7 @@ impl RunnerTask {
@@ -126,6 +127,7 @@ impl RunnerTask {
|
|
|
|
|
delay_future: None.into(), |
|
|
|
|
paused: false, |
|
|
|
|
event_send: None, |
|
|
|
|
quit_tx: None, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -290,7 +292,10 @@ impl RunnerTask {
@@ -290,7 +292,10 @@ impl RunnerTask {
|
|
|
|
|
use RunnerMsg::*; |
|
|
|
|
trace!(msg = debug(&msg), "runner_task recv"); |
|
|
|
|
match msg { |
|
|
|
|
Quit => self.running = false, |
|
|
|
|
Quit(quit_tx) => { |
|
|
|
|
self.quit_tx = Some(quit_tx); |
|
|
|
|
self.running = false; |
|
|
|
|
}, |
|
|
|
|
QueueRun(handle, section, duration) => { |
|
|
|
|
run_queue.push_back(SecRun::new(handle, section, duration)); |
|
|
|
|
} |
|
|
|
@ -343,6 +348,10 @@ impl RunnerTask {
@@ -343,6 +348,10 @@ impl RunnerTask {
|
|
|
|
|
_ = &mut self.delay_future, if self.delay_future.is_some() => delay_done() |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if let Some(quit_tx) = self.quit_tx.take() { |
|
|
|
|
let _ = quit_tx.send(()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -382,7 +391,9 @@ impl SectionRunner {
@@ -382,7 +391,9 @@ impl SectionRunner {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub async fn quit(&mut self) -> Result<()> { |
|
|
|
|
self.msg_send.send(RunnerMsg::Quit).await?; |
|
|
|
|
let (quit_tx, quit_rx) = oneshot::channel(); |
|
|
|
|
self.msg_send.send(RunnerMsg::Quit(quit_tx)).await?; |
|
|
|
|
quit_rx.await?; |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -460,7 +471,6 @@ mod test {
@@ -460,7 +471,6 @@ mod test {
|
|
|
|
|
let mut runner = SectionRunner::new(Arc::new(interface)); |
|
|
|
|
tokio::task::yield_now().await; |
|
|
|
|
runner.quit().await.unwrap(); |
|
|
|
|
tokio::task::yield_now().await; |
|
|
|
|
|
|
|
|
|
assert_eq!(quit_msg.get_count(), 1); |
|
|
|
|
assert_eq!(task_span.get_exit_count(), 1); |
|
|
|
@ -547,7 +557,6 @@ mod test {
@@ -547,7 +557,6 @@ mod test {
|
|
|
|
|
assert_section_states(&interface, &[false, false]); |
|
|
|
|
|
|
|
|
|
runner.quit().await.unwrap(); |
|
|
|
|
tokio::task::yield_now().await; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[tokio::test] |
|
|
|
@ -585,7 +594,6 @@ mod test {
@@ -585,7 +594,6 @@ mod test {
|
|
|
|
|
assert_section_states(&interface, &[false, false]); |
|
|
|
|
|
|
|
|
|
runner.quit().await.unwrap(); |
|
|
|
|
tokio::task::yield_now().await; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[tokio::test] |
|
|
|
@ -620,7 +628,6 @@ mod test {
@@ -620,7 +628,6 @@ mod test {
|
|
|
|
|
assert_section_states(&interface, &[false, false]); |
|
|
|
|
|
|
|
|
|
runner.quit().await.unwrap(); |
|
|
|
|
tokio::task::yield_now().await; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[tokio::test] |
|
|
|
@ -680,7 +687,6 @@ mod test {
@@ -680,7 +687,6 @@ mod test {
|
|
|
|
|
assert_section_states(&interface, &[false, false]); |
|
|
|
|
|
|
|
|
|
runner.quit().await.unwrap(); |
|
|
|
|
tokio::task::yield_now().await; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[tokio::test] |
|
|
|
@ -760,6 +766,5 @@ mod test {
@@ -760,6 +766,5 @@ mod test {
|
|
|
|
|
assert_eq!(event_recv.recv().await, Ok(SectionEvent::RunFinish(run3))); |
|
|
|
|
|
|
|
|
|
runner.quit().await.unwrap(); |
|
|
|
|
tokio::task::yield_now().await; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|