Constructor
# new SynchronousLock(counteropt, onBeginopt, onEndopt)
Simple Synchronous Lock implementation
for transaction management adapted from https://www.talkinghightech.com/en/creating-a-js-lock-for-a-resource/
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
counter |
number
|
<optional> |
the number of simultaneous transactions allowed. defaults to 1 |
onBegin |
function
|
<optional> |
to be called at the start of the transaction |
onEnd |
function
|
<optional> |
to be called at the conclusion of the transaction |
- Implements:
Members
Transaction.<any>
# currentTransaction Optional
Stores a reference to the currently executing transaction, allowing access to the active transaction context
Current active transaction reference
Methods
# async release(erropt) → {Promise.<void>}
Releases The lock after the conclusion of a transaction
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
err |
Error
|
<optional> |
Promise.<void>
# async submit(transaction) → {Promise.<R>}
Submits a transaction to be processed
Parameters:
| Name | Type | Description |
|---|---|---|
transaction |
Transaction
|
Promise.<R>