Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MqlWorkerPool

Hierarchy

Implements

  • IDisposable

Index

Constructors

constructor

Properties

_isDisposed

_isDisposed: boolean = false

Private cancelTimeout

cancelTimeout: number

duration in ms to wait for a cancel to complete before killing the task and worker.

cleanupTimer

cleanupTimer: any

evaluator

evaluator: IExpressionEvaluator | null

Private globals

Private maxWorkerCount

maxWorkerCount: number

number of workers to spawn

tasks

tasks: WorkerTask[]

workers

workers: MqlWorker[]

Static Private CLEANUP_INTERVAL_MS

CLEANUP_INTERVAL_MS: number = 5000

Static Private CLEANUP_KILL_AFTER_MS

CLEANUP_KILL_AFTER_MS: number = 30000

Static Private SOFT_WORKER_COUNT

SOFT_WORKER_COUNT: number = 1

Static Private StaticCache

StaticCache: StaticCache = new StaticCache()

Accessors

isDisposed

  • get isDisposed(): boolean

Methods

Private OnTaskCompleted

  • OnTaskCompleted(task: WorkerTask, value: any): void

cancelTasks

  • cancelTasks(groupId: string): void
  • Request all tasks in this group to cancel. Kill the tasks after the cancelTimeout if they cannot be gracefully stopped.

    Parameters

    • groupId: string

    Returns void

cleanupWorkers

  • cleanupWorkers(): void

dispose

  • dispose(): void

Protected disposed

  • disposed(): void

Private fillWorkerPool

  • fillWorkerPool(): any
  • Called to initially fill the worker pool and called when a worker dies.

    Returns any

Protected getSerializedGlobals

  • getSerializedGlobals(globals: ReadonlyArray<string>): object

Private getTask

  • getTask(id: string): undefined | object

killTask

  • killTask(task: WorkerTask, startNew: boolean): any
  • Kills the task's worker and signals that the task has been canceled.

    Parameters

    • task: WorkerTask
    • startNew: boolean

    Returns any

killWorker

  • killWorker(mqlWorker: MqlWorker, startNew: boolean): any
  • Terminate the worker and start a new one to replace it.

    Parameters

    • mqlWorker: MqlWorker

      worker to terminate and remove from pool

    • startNew: boolean

      if true, fill the worker pool

    Returns any

onMessage

  • onMessage(owner: MqlWorker, msgData: WorkerResponse.IMsg): void
  • Parameters

    • owner: MqlWorker
    • msgData: WorkerResponse.IMsg

    Returns void

Private onTaskCanceled

  • onTaskCanceled(task: WorkerTask): void

Private onTaskError

  • onTaskError(task: WorkerTask, error: any): void

Private removeTask

  • removeTask(task: WorkerTask): void
  • Remove the task from the queue and mark the owning worker as free.

    Parameters

    • task: WorkerTask

    Returns void

runJs

  • runJs(groupId: string, code: string, globalNames: ReadonlyArray<string>): Promise<any>
  • Parameters

    • groupId: string
    • code: string
    • globalNames: ReadonlyArray<string>

    Returns Promise<any>

runMql

  • runMql(groupId: string, mql: string, globalNames: ReadonlyArray<string>): Promise<any>
  • Parameters

    • groupId: string
    • mql: string
    • globalNames: ReadonlyArray<string>

    Returns Promise<any>

Private startNewTask

  • startNewTask(groupId: string, globalNames: ReadonlyArray<string>, start: function): Promise<any>
  • Cancel tasks in this group and queue the new task

    Parameters

    • groupId: string
    • globalNames: ReadonlyArray<string>
    • start: function
        • (task: WorkerTask): void
        • Parameters

          • task: WorkerTask

          Returns void

    Returns Promise<any>

tryRunningTasks

  • tryRunningTasks(): any
  • Start running queued tasks if there are any available workers.

    Returns any

Generated using TypeDoc