Skip to content

Commit f7f0403

Browse files
authored
fix(runtime): forget op if no current runtime (#338)
* fix(runtime): forget op if no current runtime * feat(runtime): prepare for bug fix
1 parent 3628b0f commit f7f0403

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

compio-runtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "compio-runtime"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
description = "High-level runtime for compio"
55
categories = ["asynchronous"]
66
keywords = ["async", "runtime"]

compio-runtime/src/runtime/op.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ impl<T: OpCode> Future for OpFlagsFuture<T> {
3838
impl<T: OpCode> Drop for OpFlagsFuture<T> {
3939
fn drop(&mut self) {
4040
if let Some(key) = self.key.take() {
41-
Runtime::with_current(|r| r.cancel_op(key))
41+
// If there's no runtime, it's OK to forget it.
42+
Runtime::try_with_current(|r| r.cancel_op(key)).ok();
4243
}
4344
}
4445
}

compio-runtime/src/runtime/time.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ impl Future for TimerFuture {
144144

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

0 commit comments

Comments
 (0)