Lean
$LEAN_TAG$
|
Used to control the rate of some occurrence per unit of time. More...
Public Member Functions | |
RateGate (int occurrences, TimeSpan timeUnit) | |
Initializes a RateGate with a rate of occurrences per timeUnit . More... | |
bool | WaitToProceed (int millisecondsTimeout) |
Blocks the current thread until allowed to proceed or until the specified timeout elapses. More... | |
bool | WaitToProceed (TimeSpan timeout) |
Blocks the current thread until allowed to proceed or until the specified timeout elapses. More... | |
void | WaitToProceed () |
Blocks the current thread indefinitely until allowed to proceed. More... | |
void | Dispose () |
Releases unmanaged resources held by an instance of this class. More... | |
Protected Member Functions | |
virtual void | Dispose (bool isDisposing) |
Releases unmanaged resources held by an instance of this class. More... | |
Properties | |
int | Occurrences [get] |
Number of occurrences allowed per unit of time. More... | |
int | TimeUnitMilliseconds [get] |
The length of the time unit, in milliseconds. More... | |
bool | IsRateLimited [get] |
Flag indicating we are currently being rate limited More... | |
Used to control the rate of some occurrence per unit of time.
To control the rate of an action using a RateGate, code should simply call WaitToProceed() prior to performing the action. WaitToProceed() will block the current thread until the action is allowed based on the rate limit.
This class is thread safe. A single RateGate instance may be used to control the rate of an occurrence across multiple threads.
Definition at line 40 of file RateGate.cs.
QuantConnect.Util.RateGate.RateGate | ( | int | occurrences, |
TimeSpan | timeUnit | ||
) |
Initializes a RateGate with a rate of occurrences per timeUnit .
occurrences | Number of occurrences allowed per unit of time. |
timeUnit | Length of the time unit. |
ArgumentOutOfRangeException | If occurrences or timeUnit is negative. |
Definition at line 88 of file RateGate.cs.
bool QuantConnect.Util.RateGate.WaitToProceed | ( | int | millisecondsTimeout | ) |
Blocks the current thread until allowed to proceed or until the specified timeout elapses.
millisecondsTimeout | Number of milliseconds to wait, or -1 to wait indefinitely. |
Definition at line 159 of file RateGate.cs.
bool QuantConnect.Util.RateGate.WaitToProceed | ( | TimeSpan | timeout | ) |
Blocks the current thread until allowed to proceed or until the specified timeout elapses.
timeout |
Definition at line 190 of file RateGate.cs.
void QuantConnect.Util.RateGate.WaitToProceed | ( | ) |
Blocks the current thread indefinitely until allowed to proceed.
Definition at line 198 of file RateGate.cs.
void QuantConnect.Util.RateGate.Dispose | ( | ) |
Releases unmanaged resources held by an instance of this class.
Definition at line 213 of file RateGate.cs.
|
protectedvirtual |
Releases unmanaged resources held by an instance of this class.
isDisposing | Whether this object is being disposed. |
Definition at line 223 of file RateGate.cs.
|
get |
Number of occurrences allowed per unit of time.
Definition at line 59 of file RateGate.cs.
|
get |
The length of the time unit, in milliseconds.
Definition at line 67 of file RateGate.cs.
|
get |
Flag indicating we are currently being rate limited
Definition at line 75 of file RateGate.cs.