Skip to content

Commit 40ccaed

Browse files
committed
fix(runtime): mark Runtime !Send
1 parent a7ca69d commit 40ccaed

File tree

1 file changed

+6
-0
lines changed
  • compio-runtime/src/runtime

1 file changed

+6
-0
lines changed

compio-runtime/src/runtime/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use std::{
44
collections::VecDeque,
55
future::{poll_fn, ready, Future},
66
io,
7+
marker::PhantomData,
78
panic::AssertUnwindSafe,
9+
rc::Rc,
810
sync::Arc,
911
task::{Context, Poll},
1012
time::Duration,
@@ -41,6 +43,9 @@ pub struct Runtime {
4143
sync_runnables: Arc<SegQueue<Runnable>>,
4244
#[cfg(feature = "time")]
4345
timer_runtime: RefCell<TimerRuntime>,
46+
// Other fields don't make it !Send, but actually `local_runnables` implies it should be !Send,
47+
// otherwise it won't be valid if the runtime is sent to other threads.
48+
_p: PhantomData<Rc<VecDeque<Runnable>>>,
4449
}
4550

4651
impl Runtime {
@@ -61,6 +66,7 @@ impl Runtime {
6166
sync_runnables: Arc::new(SegQueue::new()),
6267
#[cfg(feature = "time")]
6368
timer_runtime: RefCell::new(TimerRuntime::new()),
69+
_p: PhantomData,
6470
})
6571
}
6672

0 commit comments

Comments
 (0)