scryer_prolog::machine::INTERRUPT.store(true, Ordering::Relaxed);
}).unwrap();
- let mut wam = machine::Machine::new(Default::default());
- wam.run_top_level(atom!("$toplevel"), (atom!("$repl"), 1));
+ let runtime = tokio::runtime::Builder::new_multi_thread()
+ .enable_all()
+ .build()
+ .unwrap();
+
+ runtime.block_on(async move {
+ let mut wam = machine::Machine::new(Default::default());
+ wam.run_top_level(atom!("$toplevel"), (atom!("$repl"), 1));
+ });
}
use super::*;
use crate::machine::{QueryMatch, Value, QueryResolution};
- #[test]
- fn programatic_query() {
+ #[tokio::test]
+ async fn programatic_query() {
let mut machine = Machine::new_lib();
machine.load_module_string(
);
}
- #[test]
- fn failing_query() {
+ #[tokio::test]
+ async fn failing_query() {
let mut machine = Machine::new_lib();
let query = String::from(r#"triple("a",P,"b")."#);
let output = machine.run_query(query);
);
}
- #[test]
- fn complex_results() {
+ #[tokio::test]
+ async fn complex_results() {
let mut machine = Machine::new_lib();
machine.load_module_string(
"facts",
}
- #[test]
- fn consult() {
+ #[tokio::test]
+ async fn consult() {
let mut machine = Machine::new_lib();
machine.consult_module_string(
use std::io::Read;
use std::path::PathBuf;
use std::sync::atomic::AtomicBool;
-use tokio::runtime::Runtime;
use self::config::MachineConfig;
use self::parsed_results::*;
pub(super) user_output: Stream,
pub(super) user_error: Stream,
pub(super) load_contexts: Vec<LoadContext>,
- pub(super) runtime: Runtime,
}
#[derive(Debug)]
),
};
- let runtime = tokio::runtime::Runtime::new().unwrap();
-
let mut wam = Machine {
machine_st,
indices: IndexStore::new(),
user_output,
user_error,
load_contexts: vec![],
- runtime,
};
let mut lib_path = current_dir();
let address_string = address_sink.as_str(); //to_string();
let address: Uri = address_string.parse().unwrap();
- let stream = self.runtime.block_on(async {
+ let runtime = tokio::runtime::Handle::current();
+ let stream = runtime.block_on(async {
let https = HttpsConnector::new();
let client = Client::builder()
.build::<_, hyper::Body>(https);
let (tx, rx) = channel(1);
let tx = Arc::new(Mutex::new(tx));
- let _guard = self.runtime.enter();
+ let runtime = tokio::runtime::Handle::current();
+ let _guard = runtime.enter();
let server = match Server::try_bind(&addr) {
Ok(server) => server,
Err(_) => {
}
};
- self.runtime.spawn(async move {
+ runtime.spawn(async move {
let make_svc = make_service_fn(move |_conn| {
let tx = tx.clone();
async move { Ok::<_, Infallible>(service_fn(move |req| http::serve_req(req, tx.clone()))) }
let query_cell = string_as_cstr_cell!(query_atom);
let hyper_req = request.request;
- let buf = self.runtime.block_on(async {hyper::body::aggregate(hyper_req).await.unwrap()});
+ let runtime = tokio::runtime::Handle::current();
+ let buf = runtime.block_on(async {hyper::body::aggregate(hyper_req).await.unwrap()});
let reader = buf.reader();
let mut stream = Stream::from_http_stream(