summaryrefslogtreecommitdiff
path: root/src/handlers.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-09-24 22:46:36 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-09-25 17:02:49 -0400
commitb088b58f7664cbb2fcb1e12f8aa439d377f56d49 (patch)
treea3cd8a4e40e06c55c76d3465b4e11b8b85b88abb /src/handlers.rs
parent4fd2b19f640d19e57511eb142b63e16c879ef6fd (diff)
Add SetGlobalTimeout().
To be used for a timers implementation soon.
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index c914df36d..42becc0b0 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -45,6 +45,7 @@ pub fn msg_from_js(state: Arc<IsolateState>, bytes: &[u8]) -> (bool, Box<Op>) {
msg::Any::Start => handle_start,
msg::Any::CodeFetch => handle_code_fetch,
msg::Any::CodeCache => handle_code_cache,
+ msg::Any::SetTimeout => handle_set_timeout,
msg::Any::Environ => handle_env,
msg::Any::FetchReq => handle_fetch_req,
msg::Any::TimerStart => handle_timer_start,
@@ -236,6 +237,15 @@ fn handle_code_cache(state: Arc<IsolateState>, base: &msg::Base) -> Box<Op> {
}()))
}
+fn handle_set_timeout(state: Arc<IsolateState>, base: &msg::Base) -> Box<Op> {
+ let msg = base.msg_as_set_timeout().unwrap();
+ let val = msg.timeout() as isize;
+ state
+ .timeout
+ .swap(val, std::sync::atomic::Ordering::Relaxed);
+ ok_future(empty_buf())
+}
+
fn handle_set_env(state: Arc<IsolateState>, base: &msg::Base) -> Box<Op> {
let msg = base.msg_as_set_env().unwrap();
let key = msg.key().unwrap();