Skip to content

Commit 4850e34

Browse files
committed
Run tasks at interrupt time
1 parent c911f0c commit 4850e34

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

crates/ark/src/interface.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,7 @@ impl RMain {
599599
loop {
600600
// Release the R runtime lock while we're waiting for input.
601601
self.runtime_lock_guard = None;
602-
603-
// Run pending task, one at a time
604-
if !self.tasks_rx.is_empty() {
605-
let mut task = self.tasks_rx.recv().unwrap();
606-
task.fulfill();
607-
}
602+
self.run_one_task();
608603

609604
// FIXME: Race between interrupt and new code request. To fix
610605
// this, we could manage the Shell and Control sockets on the
@@ -883,6 +878,8 @@ impl RMain {
883878
/// Invoked by the R event loop
884879
fn polled_events(&mut self) {
885880
// Check for pending tasks.
881+
self.run_one_task();
882+
886883
let count = R_RUNTIME_LOCK_COUNT.load(std::sync::atomic::Ordering::Acquire);
887884
if count == 0 {
888885
return;
@@ -936,6 +933,14 @@ impl RMain {
936933
graphics_device::on_process_events();
937934
}
938935

936+
fn run_one_task(&mut self) {
937+
// Run pending task, one at a time
938+
if !self.tasks_rx.is_empty() {
939+
let mut task = self.tasks_rx.recv().unwrap();
940+
task.fulfill();
941+
}
942+
}
943+
939944
fn send_dap(&self, event: DapBackendEvent) {
940945
let dap = self.dap.lock().unwrap();
941946
if let Some(tx) = &dap.backend_events_tx {

0 commit comments

Comments
 (0)