Skip to main content

Class: ResourceModerator<T>

Moderates access to a resource.

Type parameters

NameType
Tvoid

Constructors

constructor

new ResourceModerator<T>(resource): ResourceModerator<T>

Constructor.

Type parameters

NameType
Tvoid

Parameters

NameTypeDescription
resourceTThis resource controlled by this moderator.

Returns

ResourceModerator<T>

Defined in

src/sdk/utils/resource/ResourceModerator.ts:37

Methods

claim

claim(consumer): void

Makes a claim to this moderator's resource. If the resource is not currently owned, or the claiming consumer has a higher priority than the current owner, access will attempt to pass to the claiming consumer. Otherwise, the claiming consumer will enter a queue. After entering the queue, a consumer will gain access to the claimed resource when all other consumers with a higher priority forfeit their claims to the resource.

Parameters

NameTypeDescription
consumerResourceConsumer<T>The consumer claiming the resource.

Returns

void

Defined in

src/sdk/utils/resource/ResourceModerator.ts:47


forfeit

forfeit(consumer): void

Forfeits a claim to this moderator's resource. If the consumer forfeiting its claim is the current owner of the resource, it will immediately lose access to the resource, and access will attempt to pass to the next-highest priority consumer with a claim to the resource. Otherwise, the forfeiting consumer will be removed from the queue to gain access to the resource.

Parameters

NameTypeDescription
consumerResourceConsumer<T>The consumer that is forfeiting its claim.

Returns

void

Defined in

src/sdk/utils/resource/ResourceModerator.ts:96