diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-08-24 17:31:14 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-08-24 08:31:14 -0700 |
commit | 137f33733d365026903d40e7cde6e34ac6c36dcf (patch) | |
tree | e8096e119c374b199cd498ccfa1ee0ef4e6ba950 /js/timers.ts | |
parent | 79f82cf10ed1dbf91346994250d7311a4d74377a (diff) |
port more ops to JSON (#2809)
Diffstat (limited to 'js/timers.ts')
-rw-r--r-- | js/timers.ts | 14 |
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(); } |