Skip to main content

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

ParameterType
elementsIterable<T>

Returns

Semaphore<T>

Properties

PropertyModifierType
sizereadonlynumber

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

ParameterType
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

ParameterType
abort?AbortSignal

Returns

Promise<{ item: T; release: UnlockFn; }>