Interface ITokenBucket
This interface defines a token bucket system. One instance represents one recurring bucket with a certain limit of tokens per timespan.
Namespace: MingweiSamuel.Camille.Util
Assembly: Camille.dll
Syntax
public interface ITokenBucket
Methods
| Improve this Doc View SourceGetDelay()
Get the delay til the next available token, or -1 if a token is available.
Declaration
long GetDelay()
Returns
Type | Description |
---|---|
System.Int64 | Delay in ticks or -1 |
GetTickSpan()
Get the timespan of this bucket in ticks.
Declaration
long GetTickSpan()
Returns
Type | Description |
---|---|
System.Int64 | Timespan of the bucket. |
GetTokens(Int32)
Gets n tokens, regardless of whether they are available.
Declaration
bool GetTokens(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | Number of tokens to take. |
Returns
Type | Description |
---|---|
System.Boolean | True if the tokens were obtained without violating limits, false otherwise. |
GetTotalLimit()
Get the total limit of this bucket per timespan.
Declaration
int GetTotalLimit()
Returns
Type | Description |
---|---|
System.Int32 | Total limit per timespan. |