Constructor
new JobQueue(numParallelopt, capacityopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
numParallel |
Number |
<optional> |
1 | Optional. Defaults to 1. |
capacity |
Number |
<optional> |
Optional. The maximum capacity of this JobQueue. Only has an effect if the chosen policy is not set to ignore excess items. The maximum capacity is the total amount of Jobs either currently running or in the backlog this JobQueue can accomodate. | |
Optional. |
JobQueueCapacityPolicy | Number | The policy to use when the maximum capacity is reached, and new items are being enqueued. |
- Source:
Members
backlog
- Source:
currentJobs :ConstrainedQueue.<Job>
Type:
- Source:
isBusy
- Source:
isIdle
- Source:
isPaused
- Source:
isWorking
- Source:
load
- Source:
numJobsDone
- Source:
numJobsFailed
- Source:
numJobsRunning
- Source:
observableDone :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Source:
observableFailed :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Source:
observableIdle :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Source:
observableRun :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Source:
queue :Queue.<Job>
Type:
- Source:
utilization
- Source:
workDone
- Source:
workFailed
- Source:
Methods
addJob(job) → {this}
Add a Job to this Queue. Can either be an instance of Job or an
async function.
Parameters:
Name | Type | Description |
---|---|---|
job |
Job.<T> | producerHandler.<Promise.<T>> |
- Source:
Returns:
- Type
- this
addJobs(…jobs) → {this}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
jobs |
Job.<T> | producerHandler.<Promise.<T>> |
<repeatable> |
- Source:
Returns:
- Type
- this
addSyncJob(job) → {this}
Parameters:
Name | Type | Description |
---|---|---|
job |
producerHandler.<T> | A synchronous function to be used as a Job. |
- Source:
Returns:
- Type
- this
addSyncJobs(…jobs) → {this}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
jobs |
producerHandler.<T> |
<repeatable> |
Many synchronous functions to add as Jobs. |
- Source:
Returns:
- Type
- this
clearBacklog() → {Array.<Job.<T>>}
Removes all jobs from the backlog and returns them.
- Source:
Returns:
An array with all not yet run jobs.
- Type
- Array.<Job.<T>>
hasJob(job, eqCompareropt) → {Boolean}
Determines if a specific Job is on the backlog of this JobQueue.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
job |
Job.<T> | The job to check for | |
eqComparer |
EqualityComparer.<Job.<T>> |
<optional> |
Optional. A comparer to use for checking for equality. Defaults to the DefaultEqualityComparer which uses the identity operator. |
- Source:
Returns:
True, iff the Job is in the backlog.
- Type
- Boolean
isJobRunning(job, eqCompareropt) → {Boolean}
Determines if a specific Job is currently runnung on this JobQueue.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
job |
Job.<T> | The Job to check for | |
eqComparer |
EqualityComparer.<Job.<T>> |
<optional> |
Optional. A comparer to use for checking for equality. Defaults to the DefaultEqualityComparer which uses the identity operator. |
- Source:
Returns:
True, iff this JobQueue is currently processing
the given job.
- Type
- Boolean
pause() → {this}
Pauses this queue, which results in no Jobs being further pushed on the
internal processing queue. Note that already running jobs cannot be
paused. If the queue is currently busy, you need to wait for the Idle-
event by subscribing to the Observable.
- Source:
- See:
-
- {symbolIdle}
- {observableIdle}
Returns:
- Type
- this
removeJobFromBacklog(job, eqCompareropt) → {this}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
job |
Job.<T> | The Job to remove from the backlog. | |
eqComparer |
EqualityComparer.<Job.<T>> |
<optional> |
Optional. A comparer to use for checking for equality. Defaults to the DefaultEqualityComparer which uses the identity operator. |
- Source:
Returns:
- Type
- this
resume() → {this}
Un-pauses this queue and immediately checks for work that can be done.
- Source:
Returns:
- Type
- this
runToCompletion() → {Promise.<void>}
Runs all jobs currently enqueued and then resolves when all are done. If
the queue was paused, it will be resumed. Adding more jobs while this call
is not resolved will defer it.
- Source:
Returns:
That will resolve if the queue's current load
is 0 (no jobs running and none in the backlog) or once it reaches 0 (if
all currently enqueued jobs are done). The Promise is rejected if any of
the jobs fails.
- Type
- Promise.<void>