Semaphore Class
Package: @esfx/threading-semaphore
Declaration
export declare class Semaphore
Constructors
constructor(initialCount, maxCount)
Constructs a new instance of the Semaphore
class
Declaration
constructor(initialCount: number, maxCount?: number);
Parameters
- initialCount
- number
- maxCount
- number
constructor(buffer, byteOffset)
Constructs a new instance of the Semaphore
class
Declaration
constructor(buffer: SharedArrayBuffer, byteOffset?: number);
Parameters
- buffer
- SharedArrayBuffer
- byteOffset
- number
Properties
buffer
Gets the SharedArrayBuffer
for this object.
Declaration
get buffer(): SharedArrayBuffer;
Property Value
byteLength
Gets the number of bytes occupied by this object in its buffer.
Declaration
get byteLength(): number;
Property Value
byteOffset
Gets the byte offset of this object in its buffer.
Declaration
get byteOffset(): number;
Property Value
count
Gets the number of remaining threads that can enter the semaphore.
Declaration
get count(): number;
Property Value
SIZE
Declaration
static readonly SIZE = 16;
Methods
[Disposable.dispose]()
Releases all resources for this object.
Declaration
[Disposable.dispose](): void;
Returns
void
close()
Releases all resources for this object.
Declaration
close(): void;
Returns
void
release(count)
Exits the semaphore the provided number of times.
Declaration
release(count?: number): number;
Parameters
Returns
The previous count of the semaphore.
wait(ms)
Blocks the current thread until it can enter the semaphore.
Declaration
wait(ms?: number): boolean;
Parameters
Returns
true
if the semaphore was entered before the timeout elapsed; otherwise, false
.