AsyncLockOptions interface
プロパティ
| domain |
同じドメインにロックを再入します。 「例」
|
| max |
ロックの取得から実行の完了までの最大時間。 |
| max |
キューに入って実行を完了する間に許容される最大時間。 |
| max |
キューで一度に許可されるタスクの最大数。 |
| Promise | グローバル 「例」
|
| skip |
キューの先頭にあるタスクをエンキューし、エンキューされたすべてのタスクをスキップできます。 「例」
|
| timeout | ロックを取得する前に、項目をキューに残すことができる最大時間。 |
プロパティの詳細
domainReentrant
同じドメインにロックを再入します。
「例」
import AsyncLock = require('async-lock');
import * as domain from 'domain';
const lock = new AsyncLock({ domainReentrant: true });
const d = domain.create();
d.run(() => {
lock.acquire('key', () => {
// Enter lock
return lock.acquire('key', () => {
// Enter same lock twice
});
});
});
domainReentrant?: boolean
プロパティ値
boolean
maxExecutionTime
ロックの取得から実行の完了までの最大時間。
maxExecutionTime?: number
プロパティ値
number
maxOccupationTime
キューに入って実行を完了する間に許容される最大時間。
maxOccupationTime?: number
プロパティ値
number
maxPending
キューで一度に許可されるタスクの最大数。
maxPending?: number
プロパティ値
number
Promise
グローバル Promise 変数の代わりに、独自の Promise ライブラリを使用します。
「例」
import AsyncLock = require('async-lock');
import Bluebird = require('bluebird');
import Q = require('q');
new AsyncLock({ Promise: Bluebird }); // Bluebird
new AsyncLock({ Promise: Q }); // Q
Promise?: unknown
プロパティ値
unknown
skipQueue
キューの先頭にあるタスクをエンキューし、エンキューされたすべてのタスクをスキップできます。
「例」
import AsyncLock = require('async-lock');
const lock = new AsyncLock();
// Add a task to the front of the queue waiting for a given lock
lock.acquire(key, fn1, cb); // runs immediately
lock.acquire(key, fn2, cb); // added to queue
lock.acquire(key, priorityFn, cb, { skipQueue: true }); // jumps queue and runs before fn2
skipQueue?: boolean
プロパティ値
boolean
timeout
ロックを取得する前に、項目をキューに残すことができる最大時間。
timeout?: number
プロパティ値
number