summaryrefslogtreecommitdiff
path: root/js/timers.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-08-24 13:20:48 -0700
committerGitHub <noreply@github.com>2019-08-24 13:20:48 -0700
commit2235dd795d3cc6c24ff1bdd1bbdcd110b4b0bdfc (patch)
treea5811adc062cbb1c66f05c863c9be245cf4fd2d2 /js/timers.ts
parentbdc0a13261deaa3748f51d9948b4e7b92864c324 (diff)
Revert json ops (#2814)
* Revert "port more ops to JSON (#2809)" This reverts commit 137f33733d365026903d40e7cde6e34ac6c36dcf. * Revert "port ops to JSON: compiler, errors, fetch, files (#2804)" This reverts commit 79f82cf10ed1dbf91346994250d7311a4d74377a. * Revert "Port rest of os ops to JSON (#2802)" This reverts commit 5b2baa5c990fbeae747e952c5dcd7a5369e950b1.
Diffstat (limited to 'js/timers.ts')
-rw-r--r--js/timers.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/js/timers.ts b/js/timers.ts
index 079e779c4..cb0fd531c 100644
--- a/js/timers.ts
+++ b/js/timers.ts
@@ -1,8 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { assert } from "./util";
+import { sendAsync, sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
import { window } from "./window";
-import * as dispatch from "./dispatch";
-import { sendSync, sendAsync } from "./dispatch_json";
interface Timer {
id: number;
@@ -38,8 +37,11 @@ function getTime(): number {
}
function clearGlobalTimeout(): void {
+ const builder = flatbuffers.createBuilder();
+ const inner = msg.GlobalTimerStop.createGlobalTimerStop(builder);
globalTimeoutDue = null;
- sendSync(dispatch.OP_GLOBAL_TIMER_STOP);
+ let res = sendSync(builder, msg.Any.GlobalTimerStop, inner);
+ assert(res == null);
}
async function setGlobalTimeout(due: number, now: number): Promise<void> {
@@ -50,8 +52,12 @@ async function setGlobalTimeout(due: number, now: number): Promise<void> {
assert(timeout >= 0);
// Send message to the backend.
+ const builder = flatbuffers.createBuilder();
+ msg.GlobalTimer.startGlobalTimer(builder);
+ msg.GlobalTimer.addTimeout(builder, timeout);
+ const inner = msg.GlobalTimer.endGlobalTimer(builder);
globalTimeoutDue = due;
- await sendAsync(dispatch.OP_GLOBAL_TIMER, { timeout });
+ await sendAsync(builder, msg.Any.GlobalTimer, inner);
// eslint-disable-next-line @typescript-eslint/no-use-before-define
fireTimers();
}