Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ScheduledParallelStream<TSubResult, TEndResult>

Stream that has been scheduled on the thread pool and waits for completion of its tasks.

Type parameters

  • TSubResult

    type of the sub results

  • TEndResult

    type of the end result

Hierarchy

  • ScheduledParallelStream

Implements

Index

Constructors

constructor

Properties

Private endResult

endResult: TEndResult | undefined

The accumulated end result for all yet completed tasks. Is undefined if the stream is complete.

Private failed

failed: boolean = false

Indicator if any task has failed. If this is the case, then registered next handlers are no longer called for outstanding results.

type

{boolean}

Private innerStream

innerStream: ParallelStream<TSubResult, TEndResult>

Private joiner

joiner: function

Function used to join the sub results to the end result

Type declaration

    • (memo: TSubResult, current: TSubResult): TEndResult
    • Parameters

      • memo: TSubResult
      • current: TSubResult

      Returns TEndResult

Private next

next: function

Type declaration

    • (subResult: TSubResult, task: number, valuesPerTask: number): void
    • Parameters

      • subResult: TSubResult
      • task: number
      • valuesPerTask: number

      Returns void

Private nextSubResultIndex

nextSubResultIndex: number = 0

The index of the next expected sub result that should be joined with the end result

Private pending

pending: number

Number of still pending tasks

Private reject

reject: function

Rejects the _promise with the given reason

Type declaration

    • (reason: any): void
    • Parameters

      • reason: any

      Returns void

Private resolve

resolve: function

Resolves the _promise with the given end result

Type declaration

    • (result: TEndResult): void
    • Parameters

      • result: TEndResult

      Returns void

Private subResults

subResults: Array<TSubResult | undefined>

Not yet joined sub results

Private tasks

tasks: Array<ITask<TSubResult> | undefined>

The tasks executed by this stream. Already completed tasks are replaced with undefined to free the reference to the task (gc can collect the task)

Methods

Private _taskCompleted

Private _taskFailed

  • _taskFailed(reason: any): void

catch

  • catch<TResult>(onrejected: function): Promise<TResult | TEndResult>
  • catch(onrejected: function): Promise<TEndResult>

Private joinSubResults

  • joinSubResults(): void
  • Joins the currently outstanding sub results. The sub results is needed to ensure that the results are joined in task order. This method iterates until it either reaches the end of the sub results or a sub result for a task is missing (undefined, not yet computed). Has a better memory footprint compared to if all subresults are kept.

    Returns void

Private registerTaskHandler

  • registerTaskHandler(task: ITask<TSubResult>): void

subscribe

  • subscribe(onNext: function, onError?: undefined | function, onComplete?: undefined | function): IParallelStream<TSubResult, TEndResult>
  • Parameters

    • onNext: function
        • (subResult: TSubResult, worker: number, valuesPerWorker: number): void
        • Parameters

          • subResult: TSubResult
          • worker: number
          • valuesPerWorker: number

          Returns void

    • Optional onError: undefined | function
    • Optional onComplete: undefined | function

    Returns IParallelStream<TSubResult, TEndResult>

then

  • then<TResult1, TResult2>(onfulfilled: function, onrejected: function): Promise<TResult2 | TResult1>
  • then<TResult>(onfulfilled: function, onrejected: function): Promise<TResult>
  • then<TResult>(onfulfilled: function): Promise<TResult>
  • then<TResult>(onfulfilled?: undefined | function, onrejected?: undefined | function): Promise<TResult>
  • then<TResult>(onfulfilled?: undefined | function, onrejected?: undefined | function): Promise<TResult>
  • Type parameters

    • TResult1

    • TResult2

    Parameters

    • onfulfilled: function
        • (value: TEndResult): TResult1 | PromiseLike<TResult1>
        • Parameters

          • value: TEndResult

          Returns TResult1 | PromiseLike<TResult1>

    • onrejected: function
        • (reason: any): TResult2 | PromiseLike<TResult2>
        • Parameters

          • reason: any

          Returns TResult2 | PromiseLike<TResult2>

    Returns Promise<TResult2 | TResult1>

  • Type parameters

    • TResult

    Parameters

    • onfulfilled: function
        • (value: TEndResult): TResult | PromiseLike<TResult>
        • Parameters

          • value: TEndResult

          Returns TResult | PromiseLike<TResult>

    • onrejected: function
        • (reason: any): TResult | PromiseLike<TResult>
        • Parameters

          • reason: any

          Returns TResult | PromiseLike<TResult>

    Returns Promise<TResult>

  • Type parameters

    • TResult

    Parameters

    • onfulfilled: function
        • (value: TEndResult): TResult | PromiseLike<TResult>
        • Parameters

          • value: TEndResult

          Returns TResult | PromiseLike<TResult>

    Returns Promise<TResult>

  • Type parameters

    • TResult

    Parameters

    • Optional onfulfilled: undefined | function
    • Optional onrejected: undefined | function

    Returns Promise<TResult>

  • Type parameters

    • TResult

    Parameters

    • Optional onfulfilled: undefined | function
    • Optional onrejected: undefined | function

    Returns Promise<TResult>

Generated using TypeDoc