Skip to content

Commit

Permalink
fix(runtime): wrap runnable queue with Arc to make it Send & Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Nov 24, 2024
1 parent cb8d86c commit 9118904
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compio-runtime/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
io,
panic::AssertUnwindSafe,
rc::Rc,
sync::Arc,
task::Poll,
time::Duration,
};
Expand Down Expand Up @@ -85,7 +86,7 @@ impl RunnableQueue {
/// sent to other threads.
pub struct Runtime {
driver: Rc<RefCell<Proactor>>,
runnables: Rc<RunnableQueue>,
runnables: Arc<RunnableQueue>,
#[cfg(feature = "time")]
timer_runtime: Rc<RefCell<TimerRuntime>>,
event_interval: usize,
Expand All @@ -105,7 +106,7 @@ impl Runtime {
fn with_builder(builder: &RuntimeBuilder) -> io::Result<Self> {
Ok(Self {
driver: Rc::new(RefCell::new(builder.proactor_builder.build()?)),
runnables: Rc::new(RunnableQueue::new()),
runnables: Arc::new(RunnableQueue::new()),
#[cfg(feature = "time")]
timer_runtime: Rc::new(RefCell::new(TimerRuntime::new())),
event_interval: builder.event_interval,
Expand Down Expand Up @@ -152,7 +153,7 @@ impl Runtime {
///
/// The caller should ensure the captured lifetime long enough.
pub unsafe fn spawn_unchecked<F: Future>(&self, future: F) -> Task<F::Output> {
let runnables = Rc::downgrade(&self.runnables);
let runnables = Arc::downgrade(&self.runnables);
let handle = self
.driver
.borrow()
Expand Down

0 comments on commit 9118904

Please sign in to comment.