Skip to content

Commit

Permalink
chore: let makeRunUtils caller provide run policy
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Nov 22, 2024
1 parent 64c1f9d commit f5c74ea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/SwingSet/tools/run-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand Down

0 comments on commit f5c74ea

Please sign in to comment.