new Locker(parent, addnullable, limitnullable)
Represents a mutex lock for locking asynchronous object methods.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parent |
function | Parent constructor. |
|
add |
function |
<nullable> |
|
limit |
Number |
<nullable> |
Limit in bytes of data that can be queued. |
- Source:
Methods
destroy()
Destroy the locker. Purge all pending calls.
- Source:
hasPending(key) → {Boolean}
Test whether the locker has a pending object by key (usually a Hash).
Parameters:
Name | Type | Description |
---|---|---|
key |
Hash | String |
- Source:
Returns:
- Type
- Boolean
lock(func, args, forcenullable) → {function}
Lock the parent object and all its methods which use the locker. Begin to queue calls.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
func |
function | The method being called. |
|
args |
Array | Arguments passed to the method. |
|
force |
Boolean |
<nullable> |
Force a call. |
- Source:
Returns:
unlock - Unlocker - must be called once the method finishes executing in order to resolve the queue.
- Type
- function
onDrain(callback)
Wait for a drain (empty queue).
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
purgePending()
Purge all pending calls (called once add
has hit limit
).
- Source: