Semaphore<T>
Internal
An asynchronous semaphore implementation with associated items per lease.
This class is meant to be used in PowerSync SDKs only, and is not part of the public API.
Type Parameters
| Type Parameter |
|---|
T |
Constructors
new Semaphore()
new Semaphore<T>(elements): Semaphore<T>
Parameters
| Parameter | Type |
|---|---|
elements | Iterable<T> |
Returns
Semaphore<T>
Properties
| Property | Modifier | Type |
|---|---|---|
size | readonly | number |
Methods
requestAll()
requestAll(abort?): Promise<{
items: T[];
release: UnlockFn;
}>
Requests access to all items from the pool.
The returned release callback must be invoked to return items into the pool.
Parameters
| Parameter | Type |
|---|---|
abort? | AbortSignal |
Returns
Promise<{
items: T[];
release: UnlockFn;
}>
requestOne()
requestOne(abort?): Promise<{
item: T;
release: UnlockFn;
}>
Requests a single item from the pool.
The returned release callback must be invoked to return the item into the pool.
Parameters
| Parameter | Type |
|---|---|
abort? | AbortSignal |
Returns
Promise<{
item: T;
release: UnlockFn;
}>