From a42a58b15527f88fcb4b425414b068cad0b03349 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 29 Oct 2017 04:04:54 -0700 Subject: [PATCH] Don't need mutex, kill it --- src/main.rs | 2 +- src/webapp.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 198644f..7518f52 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ include!(concat!(env!("OUT_DIR"), "/static.rs")); #[link_args="-ltinfo"] extern { } -type PLIGenerator = Box Box + Send>; +type PLIGenerator = Box Box + Send + Sync>; fn main() { let languages: Vec> = diff --git a/src/webapp.rs b/src/webapp.rs index 5d0023d..11120ed 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -6,7 +6,6 @@ use rocket_contrib::Json; use language::{ProgrammingLanguageInterface, EvalOptions}; use WEBFILES; use ::PLIGenerator; -use std::sync::Mutex; #[get("/")] fn index() -> Content { @@ -33,12 +32,12 @@ struct Output { } #[post("/input", format = "application/json", data = "")] -fn interpreter_input(input: Json, schala_gen: State>) -> Json { - let mut schala: Box = schala_gen.lock().unwrap()(); +fn interpreter_input(input: Json, schala_gen: State) -> Json { + let mut schala: Box = schala_gen(); let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default()); Json(Output { text: code_output.to_string() }) } pub fn web_main(language_generators: Vec>, func: PLIGenerator) { - rocket::ignite().manage(Mutex::new(func)).mount("/", routes![index, js_bundle, interpreter_input]).launch(); + rocket::ignite().manage(func).mount("/", routes![index, js_bundle, interpreter_input]).launch(); }