Make latency consistent across all cps

This commit is contained in:
Aria 2026-01-10 11:20:17 -06:00
parent 4743334a17
commit d753eedb90
3 changed files with 15 additions and 3 deletions

View file

@ -2,7 +2,7 @@ import { NeoCyclist } from './neocyclist.mjs';
import { Cyclist } from './cyclist.mjs';
import { evaluate as _evaluate } from './evaluate.mjs';
import { errorLogger, logger } from './logger.mjs';
import { setTime } from './time.mjs';
import { setCpsFunc, setTime } from './time.mjs';
import { evalScope } from './evaluate.mjs';
import { register, Pattern, isPattern, silence, stack } from './pattern.mjs';
@ -61,6 +61,7 @@ export function repl({
// NeoCyclist uses a shared worker to communicate between instances, which is not supported on mobile chrome
const scheduler =
sync && typeof SharedWorker != 'undefined' ? new NeoCyclist(schedulerOptions) : new Cyclist(schedulerOptions);
setCpsFunc(() => scheduler.cps);
let pPatterns = {};
let anonymousIndex = 0;
let allTransform;

View file

@ -1,4 +1,5 @@
let time;
let cpsFunc;
export function getTime() {
if (!time) {
throw new Error('no time set! use setTime to define a time source');
@ -9,3 +10,11 @@ export function getTime() {
export function setTime(func) {
time = func;
}
export function setCpsFunc(func) {
cpsFunc = func;
}
export function getCps() {
return cpsFunc?.();
}