From 84c527175827d65eddf46051582e205b5df92672 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 28 Oct 2024 12:29:36 -0500 Subject: [PATCH] chore: let makeRunUtils caller provide run policy --- packages/SwingSet/tools/run-utils.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/SwingSet/tools/run-utils.js b/packages/SwingSet/tools/run-utils.js index 0bb0c5e3866..d2676f1055b 100644 --- a/packages/SwingSet/tools/run-utils.js +++ b/packages/SwingSet/tools/run-utils.js @@ -2,12 +2,18 @@ import { Fail, q } from '@endo/errors'; import { kunser } from '@agoric/kmarshal'; import { makeQueue } from '@endo/stream'; -/** @import { ERef } from '@endo/far' */ +/** + * @import { ERef } from '@endo/far' + * @import { RunPolicy } from '../src/types-external.js' + */ + +/** @typedef {{ provideRunPolicy: () => RunPolicy | undefined }} RunPolicyMaker */ /** * @param {import('../src/controller/controller.js').SwingsetController} controller + * @param {RunPolicyMaker} [perfTool] */ -export const makeRunUtils = controller => { +export const makeRunUtils = (controller, perfTool) => { const mutex = makeQueue(); const logRunFailure = reason => console.log('controller.run() failure', reason); @@ -25,7 +31,8 @@ export const makeRunUtils = controller => { const queueAndRun = async (deliveryThunk, voidResult = false) => { await mutex.get(); const kpid = await deliveryThunk(); - const runResultP = controller.run(); + const runPolicy = perfTool && perfTool.provideRunPolicy(); + const runResultP = controller.run(runPolicy); mutex.put(runResultP.catch(logRunFailure)); await runResultP;