diff --git a/src/lune/scheduler/impl_runner.rs b/src/lune/scheduler/impl_runner.rs index 78cc9d3..3261401 100644 --- a/src/lune/scheduler/impl_runner.rs +++ b/src/lune/scheduler/impl_runner.rs @@ -95,14 +95,14 @@ where let mut resumed_any = false; loop { - let mut rx = self.new_thread_ready.subscribe(); + let mut rx = self.futures_break_signal.subscribe(); let mut futs = self .futures .try_lock() .expect("Failed to lock futures queue"); - // Wait until we either get a new lua thread or a future completes + // Wait until we either manually break out of resumption or a future completes tokio::select! { _res = rx.recv() => break, res = futs.next() => { diff --git a/src/lune/scheduler/impl_threads.rs b/src/lune/scheduler/impl_threads.rs index 37be2fe..7545fb1 100644 --- a/src/lune/scheduler/impl_threads.rs +++ b/src/lune/scheduler/impl_threads.rs @@ -59,8 +59,8 @@ where // NOTE: We might be resuming futures, need to signal that a // new lua thread is ready to break out of futures resumption - if self.new_thread_ready.receiver_count() > 0 { - self.new_thread_ready.send(()).ok(); + if self.futures_break_signal.receiver_count() > 0 { + self.futures_break_signal.send(()).ok(); } Ok(()) @@ -97,8 +97,8 @@ where // NOTE: We might be resuming futures, need to signal that a // new lua thread is ready to break out of futures resumption - if self.new_thread_ready.receiver_count() > 0 { - self.new_thread_ready.send(()).ok(); + if self.futures_break_signal.receiver_count() > 0 { + self.futures_break_signal.send(()).ok(); } Ok(thread_id) @@ -135,8 +135,8 @@ where // NOTE: We might be resuming futures, need to signal that a // new lua thread is ready to break out of futures resumption - if self.new_thread_ready.receiver_count() > 0 { - self.new_thread_ready.send(()).ok(); + if self.futures_break_signal.receiver_count() > 0 { + self.futures_break_signal.send(()).ok(); } Ok(thread_id) diff --git a/src/lune/scheduler/mod.rs b/src/lune/scheduler/mod.rs index b00e2b8..0e06b43 100644 --- a/src/lune/scheduler/mod.rs +++ b/src/lune/scheduler/mod.rs @@ -43,12 +43,12 @@ pub(crate) struct Scheduler<'lua, 'fut> { threads: Arc>>, thread_senders: Arc>>, futures: Arc>>>, - new_thread_ready: Sender<()>, + futures_break_signal: Sender<()>, } impl<'lua, 'fut> Scheduler<'lua, 'fut> { pub fn new(lua: &'lua Lua) -> Self { - let (new_thread_ready, _) = channel(1); + let (futures_break_signal, _) = channel(1); let this = Self { lua, @@ -56,7 +56,7 @@ impl<'lua, 'fut> Scheduler<'lua, 'fut> { threads: Arc::new(RefCell::new(VecDeque::new())), thread_senders: Arc::new(RefCell::new(HashMap::new())), futures: Arc::new(AsyncMutex::new(FuturesUnordered::new())), - new_thread_ready, + futures_break_signal, }; // Propagate errors given to the scheduler back to their lua threads