2 Commits

Author SHA1 Message Date
72755f9cf1 chore(release): v0.7.1 (#12)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.7.1

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: https://git.front.kjuulh.io/kjuulh/mad/pulls/12
2024-11-24 11:28:02 +01:00
ae0b8b703e fix: make sure to close on final
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-11-24 11:24:13 +01:00
4 changed files with 16 additions and 9 deletions

View File

@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [0.7.1] - 2024-11-24
### Fixed
- make sure to close on final
## [0.7.0] - 2024-11-24 ## [0.7.0] - 2024-11-24
### Added ### Added

2
Cargo.lock generated
View File

@@ -266,7 +266,7 @@ dependencies = [
[[package]] [[package]]
name = "notmad" name = "notmad"
version = "0.6.0" version = "0.7.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2" resolver = "2"
[workspace.package] [workspace.package]
version = "0.7.0" version = "0.7.1"
[workspace.dependencies] [workspace.dependencies]
mad = { path = "crates/mad" } mad = { path = "crates/mad" }

View File

@@ -160,18 +160,20 @@ impl Mad {
} }
tokio::spawn({ tokio::spawn({
let cancellation_token = cancellation_token.child_token(); let cancellation_token = cancellation_token;
let job_done = job_done.child_token(); let job_done = job_done.child_token();
let wait_cancel = self.should_cancel; let wait_cancel = self.should_cancel;
async move { async move {
let should_cancel = let should_cancel =
|cancel: CancellationToken, wait: Option<std::time::Duration>| async move { |cancel: CancellationToken,
global_cancel: CancellationToken,
wait: Option<std::time::Duration>| async move {
if let Some(cancel_wait) = wait { if let Some(cancel_wait) = wait {
tokio::time::sleep(cancel_wait).await;
cancel.cancel(); cancel.cancel();
tokio::time::sleep(cancel_wait).await;
global_cancel.cancel();
} }
}; };
@@ -180,13 +182,13 @@ impl Mad {
job_cancellation.cancel(); job_cancellation.cancel();
} }
_ = job_done.cancelled() => { _ = job_done.cancelled() => {
should_cancel(job_cancellation, wait_cancel).await; should_cancel(job_cancellation, cancellation_token, wait_cancel).await;
} }
_ = tokio::signal::ctrl_c() => { _ = tokio::signal::ctrl_c() => {
should_cancel(job_cancellation, wait_cancel).await; should_cancel(job_cancellation, cancellation_token,wait_cancel).await;
} }
_ = signal_unix_terminate() => { _ = signal_unix_terminate() => {
should_cancel(job_cancellation, wait_cancel).await; should_cancel(job_cancellation, cancellation_token, wait_cancel).await;
} }
} }
} }