Class SharedResourceScheduler<T>
Abstraction for handling some kind of recursive exploration. Simply a small extension to OperationScheduler<T> that uses an instance of a IResourceCounter for shared capacity.
Implements
Inherited Members
Namespace: Cognite.Extractor.Common
Assembly: Cognite.Common.dll
Syntax
public abstract class SharedResourceScheduler<T> : OperationScheduler<T>, IDisposable
Type Parameters
Name | Description |
---|---|
T | Type of item to explore |
Constructors
| Edit this page View SourceSharedResourceScheduler(IEnumerable<T>, TaskThrottler, int, IResourceCounter, CancellationToken)
Constructor
Declaration
public SharedResourceScheduler(IEnumerable<T> initialItems, TaskThrottler throttler, int chunkSize, IResourceCounter resource, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | initialItems | List of initial items, must be non-empty |
TaskThrottler | throttler | TaskThrottler to use. Can be shared with other schedulers |
int | chunkSize | Maximum number of items per chunk |
IResourceCounter | resource | Shared resource to limit parallel requests based on |
CancellationToken | token | Cancellation token |
Methods
| Edit this page View SourceFreeCapacity(int)
Free freed
capacity from the shared resource manager.
Declaration
protected override void FreeCapacity(int freed)
Parameters
Type | Name | Description |
---|---|---|
int | freed | Amount of capacity to free |
Overrides
| Edit this page View SourceGetCapacity(int, bool)
Get requested
capacity from the shared resource manager.
Returns a number between 1 and requested
, blocks if
there are zero resources available unless shouldBlock
is false,
then returns immediately.
Declaration
protected override Task<int> GetCapacity(int requested, bool shouldBlock)
Parameters
Type | Name | Description |
---|---|---|
int | requested | Amount of capacity to request |
bool | shouldBlock | True if this should block |
Returns
Type | Description |
---|---|
Task<int> | The number of resources allocated |