From 014f75838b3a178183015c530913dd374f5675ee Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 27 Nov 2019 02:15:52 -0600 Subject: [PATCH] avoid clobbering now(): rename to clock() --- ag-solo-xs-main.js | 9 ++++++--- lib/ag-solo/start.js | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ag-solo-xs-main.js b/ag-solo-xs-main.js index 1c46fa5feff..b1c6a496a30 100644 --- a/ag-solo-xs-main.js +++ b/ag-solo-xs-main.js @@ -17,14 +17,17 @@ import start from './lib/ag-solo/start'; trace("top-level executes\n"); function setImmediate(callback) { - Timer.set(callback); + // @@@not sure about this. + // https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/base/base.md#timer + // https://github.com/Agoric/SwingSet/issues/121 + Timer.set(callback, 1); } function setInterval(callback, delay) { Timer.repeat(callback, delay); } -function now() { +function clock() { return Date.now(); } @@ -86,5 +89,5 @@ async function run(argv, cwd) { const basedir = cwd.join(argv[0]); return start(basedir, withSES, argv, - { createServer, setImmediate, setInterval, now }); + { createServer, setImmediate, setInterval, clock }); } diff --git a/lib/ag-solo/start.js b/lib/ag-solo/start.js index a362d18fb7f..34e2ca7a301 100644 --- a/lib/ag-solo/start.js +++ b/lib/ag-solo/start.js @@ -52,7 +52,7 @@ async function buildSwingset( vatsDir, argv, broadcast, - { setInterval, setImmediate, now } + { setInterval, setImmediate, clock } ) { const initialMailboxState = JSON.parse(mailboxStateFile.readFileSync()); @@ -141,7 +141,7 @@ async function buildSwingset( // drop calls to moveTimeForward if it's fallen behind, to make sure we don't // have two copies of controller.run() executing at the same time. function moveTimeForward() { - const now = Math.floor(now() / intervalMillis); + const now = Math.floor(clock() / intervalMillis); if (timer.poll(now)) { const p = processKernel(); p.then( @@ -163,7 +163,7 @@ async function buildSwingset( } export default async function start(basedir, withSES, argv, - { createServer, setImmediate, setInterval, now }) { + { createServer, setImmediate, setInterval, clock }) { console.log(`@@start(${basedir}, ${withSES}, ${argv})`); const mailboxStateFile = basedir.join('swingset-mailbox-state.json'); const kernelStateFile = basedir.join('swingset-kernel-state.jsonlines'); @@ -240,7 +240,7 @@ export default async function start(basedir, withSES, argv, vatsDir, argv, broadcast, - { setInterval, setImmediate, now }, + { setInterval, setImmediate, clock }, ); ({ deliverInboundToMbx, deliverInboundCommand } = d);