X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerConstants.ts;h=dcbe2ca43caa3faec645c6e693dc04f1cb8b93f2;hb=6d52ef25c911dcb8d37ead86819b53a7fe35ef53;hp=1e2e8cdcb2227a2117695d5261928f8dceedab8f;hpb=4db8406cd780b8912b2cf3bd882a21228aba47a7;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerConstants.ts b/src/worker/WorkerConstants.ts index 1e2e8cdc..dcbe2ca4 100644 --- a/src/worker/WorkerConstants.ts +++ b/src/worker/WorkerConstants.ts @@ -1,10 +1,18 @@ -export default class WorkerConstants { - static readonly DEFAULT_ELEMENT_START_DELAY = 0; - static readonly DEFAULT_WORKER_START_DELAY = 500; - static readonly POOL_MAX_INACTIVE_TIME = 60000; - static readonly DEFAULT_POOL_MIN_SIZE = 4; - static readonly DEFAULT_POOL_MAX_SIZE = 16; - static readonly DEFAULT_ELEMENTS_PER_WORKER = 1; +import { availableParallelism } from 'poolifier'; + +export class WorkerConstants { + public static readonly EMPTY_FUNCTION = Object.freeze(() => { + /* This is intentional */ + }); + + public static readonly DEFAULT_ELEMENT_START_DELAY = 0; + public static readonly DEFAULT_WORKER_START_DELAY = 500; + public static readonly POOL_MAX_INACTIVE_TIME = 60000; + public static readonly DEFAULT_POOL_MIN_SIZE = Math.floor(availableParallelism() / 2); + public static readonly DEFAULT_POOL_MAX_SIZE = Math.round(availableParallelism() * 1.5); + public static readonly DEFAULT_ELEMENTS_PER_WORKER = 1; + + public static readonly version = '1.0.1'; private constructor() { // This is intentional