Class BlockingResourceCounter
Simple construct to count number of available instances of some shared resource.
Implements
Inherited Members
Namespace: Cognite.Extractor.Common
Assembly: Cognite.Common.dll
Syntax
public class BlockingResourceCounter : IResourceCounter
Constructors
| Edit this page View SourceBlockingResourceCounter(int)
Resource counter constructor.
Declaration
public BlockingResourceCounter(int initial)
Parameters
Type | Name | Description |
---|---|---|
int | initial | Number of resources initially available. Can safely be increased by calling Free |
Properties
| Edit this page View SourceCapacity
Reference to the total capacity of the counter.
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
int |
Count
Unsafe reference to the remaining resources. Do not use this for thread safe logic.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceFree(int)
Declaration
public void Free(int count)
Parameters
Type | Name | Description |
---|---|---|
int | count |
SetCapacity(int)
Set the capacity of the counter, may set the current count to less than 0.
Declaration
public void SetCapacity(int newCapacity)
Parameters
Type | Name | Description |
---|---|---|
int | newCapacity | New capacity |
Exceptions
Type | Condition |
---|---|
ArgumentException | If |
Take(int, bool)
Declaration
public Task<int> Take(int count, bool shouldBlock)
Parameters
Type | Name | Description |
---|---|---|
int | count | |
bool | shouldBlock |
Returns
Type | Description |
---|---|
Task<int> |