Skip to content

Commit

Permalink
fix(runtime): forget op if no current runtime (#338)
Browse files Browse the repository at this point in the history
* fix(runtime): forget op if no current runtime

* feat(runtime): prepare for bug fix
  • Loading branch information
Berrysoft authored Nov 21, 2024
1 parent 3628b0f commit f7f0403
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compio-runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "compio-runtime"
version = "0.6.0"
version = "0.6.1"
description = "High-level runtime for compio"
categories = ["asynchronous"]
keywords = ["async", "runtime"]
Expand Down
3 changes: 2 additions & 1 deletion compio-runtime/src/runtime/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ impl<T: OpCode> Future for OpFlagsFuture<T> {
impl<T: OpCode> Drop for OpFlagsFuture<T> {
fn drop(&mut self) {
if let Some(key) = self.key.take() {
Runtime::with_current(|r| r.cancel_op(key))
// If there's no runtime, it's OK to forget it.
Runtime::try_with_current(|r| r.cancel_op(key)).ok();
}
}
}
3 changes: 2 additions & 1 deletion compio-runtime/src/runtime/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ impl Future for TimerFuture {

impl Drop for TimerFuture {
fn drop(&mut self) {
Runtime::with_current(|r| r.cancel_timer(self.key));
// If there's no runtime, it's OK to forget it.
Runtime::try_with_current(|r| r.cancel_timer(self.key)).ok();
}
}

Expand Down

0 comments on commit f7f0403

Please sign in to comment.