summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index ae1ee37b1..db923a31d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,8 +1,11 @@
extern crate flatbuffers;
+extern crate futures;
extern crate libc;
extern crate msg_rs as msg_generated;
extern crate sha1;
extern crate tempfile;
+extern crate tokio;
+extern crate tokio_current_thread;
extern crate url;
#[macro_use]
extern crate log;
@@ -14,6 +17,7 @@ pub mod handlers;
use libc::c_int;
use libc::c_void;
+use std::collections::HashMap;
use std::env;
use std::ffi::CStr;
use std::ffi::CString;
@@ -91,6 +95,8 @@ type DenoException<'a> = &'a str;
pub struct Deno {
ptr: *const binding::DenoC,
dir: deno_dir::DenoDir,
+ rt: tokio::runtime::current_thread::Runtime,
+ timers: HashMap<u32, futures::sync::oneshot::Sender<()>>,
}
static DENO_INIT: std::sync::Once = std::sync::ONCE_INIT;
@@ -104,6 +110,8 @@ impl Deno {
let deno_box = Box::new(Deno {
ptr: 0 as *const binding::DenoC,
dir: deno_dir::DenoDir::new(None).unwrap(),
+ rt: tokio::runtime::current_thread::Runtime::new().unwrap(),
+ timers: HashMap::new(),
});
let deno: &'a mut Deno = Box::leak(deno_box);
let external_ptr = deno as *mut _ as *const c_void;
@@ -204,4 +212,7 @@ fn main() {
error!("{}", err);
std::process::exit(1);
});
+
+ // Start the Tokio event loop
+ d.rt.run().expect("err");
}