Add Outcome::Sleep (#323)

One half of #79
This commit is contained in:
Félix Saparelli 2022-06-16 16:07:27 +00:00
parent adc4a0a576
commit 92d05755c9
3 changed files with 11 additions and 0 deletions

View File

@ -31,6 +31,7 @@ First "stable" release of the library.
- Improvement: the event queue is explicitly closed when shutting down
- Improvement: the action worker will check if the event queue is closed more often, to shutdown early
- Improvement: `kill_on_drop` is set on Commands, which will be a little more eager to terminate processes when we're done with them
- Feature: `Outcome::Sleep` waits for a given duration ([#79](https://github.com/watchexec/watchexec/issues/79))
Other miscellaneous:

View File

@ -1,3 +1,5 @@
use std::time::Duration;
use crate::signal::process::SubSignal;
/// The outcome to execute when an action is triggered.
@ -26,6 +28,9 @@ pub enum Outcome {
/// Does nothing if the command isn't running.
Wait,
/// Sleep for some duration.
Sleep(Duration),
/// Send this signal to the command.
///
/// This does not wait for the command to complete.

View File

@ -9,6 +9,7 @@ use futures::Future;
use tokio::{
spawn,
sync::{mpsc, watch::Receiver},
time::sleep,
};
use tracing::{debug, error, trace, warn};
@ -153,6 +154,10 @@ impl OutcomeWorker {
notry!(self.process.wait())?;
}
(_, Outcome::Sleep(time)) => {
notry!(sleep(time));
}
(_, Outcome::Clear) => {
clearscreen::clear()?;
}