2020-03-09 10:18:02 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-07-06 21:45:39 -04:00
|
|
|
|
2020-03-09 10:18:02 -04:00
|
|
|
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
|
|
|
|
2020-07-06 21:45:39 -04:00
|
|
|
interface NowResponse {
|
|
|
|
seconds: number;
|
|
|
|
subsecNanos: number;
|
|
|
|
}
|
|
|
|
|
2020-03-09 10:18:02 -04:00
|
|
|
export function stopGlobalTimer(): void {
|
|
|
|
sendSync("op_global_timer_stop");
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function startGlobalTimer(timeout: number): Promise<void> {
|
|
|
|
await sendAsync("op_global_timer", { timeout });
|
|
|
|
}
|
2020-03-09 19:22:15 -04:00
|
|
|
|
|
|
|
export function now(): NowResponse {
|
|
|
|
return sendSync("op_now");
|
|
|
|
}
|