let priorityOpCounter = 0;
let runningPriorityOpCounter = 0;
async function runPriorityOp(lc, description, op) {
  const id = priorityOpCounter++;
  runningPriorityOpCounter++;
  const start = Date.now();
  lc = lc.withContext("priorityOpID", id);
  try {
    lc.debug?.(`running priority op ${description}`);
    const result = await op();
    lc.debug?.(
      `finished priority op ${description} in ${Date.now() - start} ms`
    );
    return result;
  } catch (e) {
    lc.debug?.(`failed priority op ${description} in ${Date.now() - start} ms`);
    throw e;
  } finally {
    runningPriorityOpCounter--;
  }
}
function isPriorityOpRunning() {
  return runningPriorityOpCounter > 0;
}
export {
  isPriorityOpRunning,
  runPriorityOp
};
//# sourceMappingURL=priority-op.js.map
