Rename scheduler struct member

This commit is contained in:
Filip Tibell 2023-08-20 15:12:29 -05:00
parent 57677278c4
commit dc6903cfae
3 changed files with 11 additions and 11 deletions

View file

@ -95,14 +95,14 @@ where
let mut resumed_any = false; let mut resumed_any = false;
loop { loop {
let mut rx = self.new_thread_ready.subscribe(); let mut rx = self.futures_break_signal.subscribe();
let mut futs = self let mut futs = self
.futures .futures
.try_lock() .try_lock()
.expect("Failed to lock futures queue"); .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! { tokio::select! {
_res = rx.recv() => break, _res = rx.recv() => break,
res = futs.next() => { res = futs.next() => {

View file

@ -59,8 +59,8 @@ where
// NOTE: We might be resuming futures, need to signal that a // NOTE: We might be resuming futures, need to signal that a
// new lua thread is ready to break out of futures resumption // new lua thread is ready to break out of futures resumption
if self.new_thread_ready.receiver_count() > 0 { if self.futures_break_signal.receiver_count() > 0 {
self.new_thread_ready.send(()).ok(); self.futures_break_signal.send(()).ok();
} }
Ok(()) Ok(())
@ -97,8 +97,8 @@ where
// NOTE: We might be resuming futures, need to signal that a // NOTE: We might be resuming futures, need to signal that a
// new lua thread is ready to break out of futures resumption // new lua thread is ready to break out of futures resumption
if self.new_thread_ready.receiver_count() > 0 { if self.futures_break_signal.receiver_count() > 0 {
self.new_thread_ready.send(()).ok(); self.futures_break_signal.send(()).ok();
} }
Ok(thread_id) Ok(thread_id)
@ -135,8 +135,8 @@ where
// NOTE: We might be resuming futures, need to signal that a // NOTE: We might be resuming futures, need to signal that a
// new lua thread is ready to break out of futures resumption // new lua thread is ready to break out of futures resumption
if self.new_thread_ready.receiver_count() > 0 { if self.futures_break_signal.receiver_count() > 0 {
self.new_thread_ready.send(()).ok(); self.futures_break_signal.send(()).ok();
} }
Ok(thread_id) Ok(thread_id)

View file

@ -43,12 +43,12 @@ pub(crate) struct Scheduler<'lua, 'fut> {
threads: Arc<RefCell<VecDeque<SchedulerThread>>>, threads: Arc<RefCell<VecDeque<SchedulerThread>>>,
thread_senders: Arc<RefCell<HashMap<SchedulerThreadId, SchedulerThreadSender>>>, thread_senders: Arc<RefCell<HashMap<SchedulerThreadId, SchedulerThreadSender>>>,
futures: Arc<AsyncMutex<FuturesUnordered<SchedulerFuture<'fut>>>>, futures: Arc<AsyncMutex<FuturesUnordered<SchedulerFuture<'fut>>>>,
new_thread_ready: Sender<()>, futures_break_signal: Sender<()>,
} }
impl<'lua, 'fut> Scheduler<'lua, 'fut> { impl<'lua, 'fut> Scheduler<'lua, 'fut> {
pub fn new(lua: &'lua Lua) -> Self { pub fn new(lua: &'lua Lua) -> Self {
let (new_thread_ready, _) = channel(1); let (futures_break_signal, _) = channel(1);
let this = Self { let this = Self {
lua, lua,
@ -56,7 +56,7 @@ impl<'lua, 'fut> Scheduler<'lua, 'fut> {
threads: Arc::new(RefCell::new(VecDeque::new())), threads: Arc::new(RefCell::new(VecDeque::new())),
thread_senders: Arc::new(RefCell::new(HashMap::new())), thread_senders: Arc::new(RefCell::new(HashMap::new())),
futures: Arc::new(AsyncMutex::new(FuturesUnordered::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 // Propagate errors given to the scheduler back to their lua threads