new JobQueueCapabilities(capabilities, allowExclusiveJobsopt, capacityopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
capabilities |
Number | |||
allowExclusiveJobs |
Boolean |
<optional> |
false | Optional. Defaults to false. A boolean that indicates whether jobs that require the whole queue's capabilities are allowed on this queue. Such jobs have a cost equal to or higher than the queue's capabilities. |
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:
Extends
Members
backlog :Number
Returns the amount of jobs on this queue that are waiting
to be processed.
Type:
- Number
- Overrides:
- Source:
backlogCost :Number
Returns the total cost of all jobs that need to be run.
Type:
- Number
- Source:
capabilitiesFree :Number
Returns the remaining capabilities. Exclusive jobs may use more capabilities than
this queue provides. However, this property can at minimum only return 0 (zero)
(i.e. not negative values).
Type:
- Number
- Source:
capabilitiesUsed :Number
Return the accumulated cost of all currently running jobs.
Type:
- Number
- Source:
currentJobs :ConstrainedQueue.<Job>
Type:
- Overrides:
- Source:
isBusy :Boolean
Only returns true, iff the remaining capabilities are exactly 0 (zero).
Type:
- Boolean
- Overrides:
- Source:
isIdle :Boolean
Returns true if there are no jobs currently processing.
Type:
- Boolean
- Overrides:
- Source:
isPaused :Boolean
Type:
- Boolean
- Overrides:
- Source:
isWorking :Boolean
Returns true if there are any current jobs running.
Type:
- Boolean
- Overrides:
- Source:
load :Number
Returns a number that indicates the ratio between currently
running and enqueued jobs and this queue's capabilities. 0 means that
the queue is idle; a value close or equal to one means that the queue
runs at or near its full capacity and a value greater than one means
that there are exclusive jobs or a non-empty backlog of waiting jobs.
Albeit overwritten, this property can be perfectly used to compare the
load of parallel job queues.
Type:
- Number
- Overrides:
- Source:
numJobsDone :Number
Returns a value indicating how many Jobs have been done.
Type:
- Number
- Overrides:
- Source:
numJobsFailed :Number
Returns a value indicating how many Jobs have failed.
Type:
- Number
- Overrides:
- Source:
numJobsRunning :Number
Returns the amount of jobs currently running.
Type:
- Number
- Overrides:
- Source:
observableDone :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Overrides:
- Source:
observableFailed :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Overrides:
- Source:
observableIdle :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Overrides:
- Source:
observableRun :Observable.<JobQueueEvent>
Type:
- Observable.<JobQueueEvent>
- Overrides:
- Source:
queue :Queue.<Job>
Type:
- Overrides:
- Source:
utilization :Number
Returns number indicating the utilization of this queue in terms of a
ratio between used capabilities and available capabilities. Note that,
if this queue allows exclusive jobs, the utilization may be greater
than 100%. The range therefore is [0, infinity].
Type:
- Number
- Overrides:
- Source:
workDone :Number
Returns a value indicating how much work has been done in terms
of number of Jobs or their cost, depending on the queue's type.
Type:
- Number
- Overrides:
- Source:
workFailed :Number
Returns a value indicating how much work has been failed in terms
of number of Jobs or their cost, depending on the queue's type.
Type:
- Number
- Overrides:
- 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>> |
- Overrides:
- Source:
Returns:
- Type
- this
addJobs(…jobs) → {this}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
jobs |
Job.<T> | producerHandler.<Promise.<T>> |
<repeatable> |
- Overrides:
- Source:
Returns:
- Type
- this
addSyncJob(job) → {this}
Parameters:
Name | Type | Description |
---|---|---|
job |
producerHandler.<T> | A synchronous function to be used as a Job. |
- Overrides:
- Source:
Returns:
- Type
- this
addSyncJobs(…jobs) → {this}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
jobs |
producerHandler.<T> |
<repeatable> |
Many synchronous functions to add as Jobs. |
- Overrides:
- Source:
Returns:
- Type
- this
clearBacklog() → {Array.<Job.<T>>}
Removes all jobs from the backlog and returns them.
- Overrides:
- 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. |
- Overrides:
- 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. |
- Overrides:
- 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.
- Overrides:
- 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. |
- Overrides:
- Source:
Returns:
- Type
- this
resume() → {this}
Un-pauses this queue and immediately checks for work that can be done.
- Overrides:
- 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.
- Overrides:
- 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>