return to toplevel from a long running query after receiving Ctrl-C
This commit is contained in:
@@ -8,6 +8,7 @@ use prolog::forms::*;
|
||||
use prolog::heap_iter::*;
|
||||
use prolog::heap_print::*;
|
||||
use prolog::instructions::*;
|
||||
use prolog::machine::INTERRUPT;
|
||||
use prolog::machine::and_stack::*;
|
||||
use prolog::machine::attributed_variables::*;
|
||||
use prolog::machine::code_repo::CodeRepo;
|
||||
@@ -3176,6 +3177,13 @@ impl MachineState {
|
||||
lco: bool,
|
||||
use_default_cp: bool,
|
||||
) {
|
||||
let interrupted = INTERRUPT.load(std::sync::atomic::Ordering::Relaxed);
|
||||
|
||||
if INTERRUPT.compare_and_swap(interrupted, false, std::sync::atomic::Ordering::Relaxed) {
|
||||
self.fail = true;
|
||||
return;
|
||||
}
|
||||
|
||||
let mut default_call_policy: Box<CallPolicy> = Box::new(DefaultCallPolicy {});
|
||||
let call_policy = if use_default_cp {
|
||||
&mut default_call_policy
|
||||
|
||||
@@ -46,6 +46,7 @@ use std::io::{stdout, Read, Write};
|
||||
use std::mem;
|
||||
use std::ops::Index;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use termion::raw::IntoRawMode;
|
||||
|
||||
@@ -54,6 +55,10 @@ pub struct MachinePolicies {
|
||||
cut_policy: Box<CutPolicy>,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref INTERRUPT: AtomicBool = AtomicBool::new(false);
|
||||
}
|
||||
|
||||
impl MachinePolicies {
|
||||
#[inline]
|
||||
fn new() -> Self {
|
||||
|
||||
Reference in New Issue
Block a user