summaryrefslogtreecommitdiff
path: root/js/timers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/timers.ts')
-rw-r--r--js/timers.ts14
1 files changed, 4 insertions, 10 deletions
diff --git a/js/timers.ts b/js/timers.ts
index cb0fd531c..079e779c4 100644
--- a/js/timers.ts
+++ b/js/timers.ts
@@ -1,7 +1,8 @@
// 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;
@@ -37,11 +38,8 @@ function getTime(): number {
}
function clearGlobalTimeout(): void {
- const builder = flatbuffers.createBuilder();
- const inner = msg.GlobalTimerStop.createGlobalTimerStop(builder);
globalTimeoutDue = null;
- let res = sendSync(builder, msg.Any.GlobalTimerStop, inner);
- assert(res == null);
+ sendSync(dispatch.OP_GLOBAL_TIMER_STOP);
}
async function setGlobalTimeout(due: number, now: number): Promise<void> {
@@ -52,12 +50,8 @@ 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(builder, msg.Any.GlobalTimer, inner);
+ await sendAsync(dispatch.OP_GLOBAL_TIMER, { timeout });
// eslint-disable-next-line @typescript-eslint/no-use-before-define
fireTimers();
}