haveno-ts/dist/utils/TaskLooper.d.ts

30 lines
944 B
TypeScript
Raw Normal View History

2022-05-04 21:30:48 -04:00
/// <reference types="node" />
/**
* Run a task in a fixed period loop.
*/
export default class TaskLooper {
_fn: () => Promise<void>;
_isStarted: boolean;
_isLooping: boolean;
_timeout: NodeJS.Timeout | undefined;
/**
* Build the looper with a function to invoke on a fixed period loop.
*
* @param {function} fn - the async function to invoke
*/
constructor(fn: () => Promise<void>);
/**
* Start the task loop.
*
2024-04-29 08:36:22 -04:00
* @param {number} periodInMs the loop period in milliseconds
* @param {boolean} targetFixedPeriod specifies if the task should target a fixed period by accounting for run time (default false)
* @return {TaskLooper} this instance for chaining
2022-05-04 21:30:48 -04:00
*/
2024-04-29 08:36:22 -04:00
start(periodInMs: number, targetFixedPeriod: boolean): void;
2022-05-04 21:30:48 -04:00
/**
* Stop the task loop.
*/
stop(): void;
2024-04-29 08:36:22 -04:00
_runLoop(periodInMs: number, targetFixedPeriod: boolean): Promise<void>;
2022-05-04 21:30:48 -04:00
}