UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

71 lines 1.68 kB
/** * Worker manager that will terminate the worker after a timeout if it is idle. * */ export class OnDemandWorkerManager { /** * * @param {WorkerProxy} worker */ constructor(worker: WorkerProxy); /** * Number of active pending requests * @type {number} * @private */ private __request_count; /** * How long to wait before terminating the worker after it becomes idle * in milliseconds * @type {number} * @private */ private __timeout_ms; /** * ID of the timer set via setTimeout * @type {number} * @private */ private __pending_termination; /** * @type {WorkerProxy} */ worker: WorkerProxy; /** * Configure how long to wait after processing a request until deciding to shut down the worker. * The browser limits the number of workers we can have open at once, so releasing them when not in use is critical. * * @param {number} delay_ms In milliseconds */ setTimeout(delay_ms: number): void; /** * @private */ private terminate; /** * @private */ private cancelScheduledTermination; /** * * @param {number} timeout */ scheduleTermination(timeout: number): void; /** * @private */ private decrement; /** * @private */ private increment; /** * Submit a request to the worker * @template T * @param {string} name * @param {Array} [parameters] * @return {Promise<T>} */ request<T>(name: string, parameters?: any[]): Promise<T>; } //# sourceMappingURL=OnDemandWorkerManager.d.ts.map