Class: ResourceModerator<T>
Defined in: src/sdk/utils/resource/ResourceModerator.ts:27
Moderates access to a resource.
Type Parameters
Type Parameter | Default type |
---|---|
T | void |
Constructors
Constructor
new ResourceModerator<
T
>(resource
):ResourceModerator
<T
>
Defined in: src/sdk/utils/resource/ResourceModerator.ts:37
Constructor.
Parameters
Parameter | Type | Description |
---|---|---|
resource | T | This resource controlled by this moderator. |
Returns
ResourceModerator
<T
>
Methods
claim()
claim(
consumer
):void
Defined in: src/sdk/utils/resource/ResourceModerator.ts:47
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
Parameter | Type | Description |
---|---|---|
consumer | ResourceConsumer <T > | The consumer claiming the resource. |
Returns
void
forfeit()
forfeit(
consumer
):void
Defined in: src/sdk/utils/resource/ResourceModerator.ts:96
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
Parameter | Type | Description |
---|---|---|
consumer | ResourceConsumer <T > | The consumer that is forfeiting its claim. |
Returns
void