begin()
and success()
. When an event is about to proceed begin()
method is called – it does the accounting and delays the return if necessary to slow down the event stream. When the event succeeds success()
method is called – it resets the counters so that further call event processing could go at a maximum speed.
If an error occurs during event processing a call to success()
is not made. The next call to begin()
will notice this and will attempt to slow down the event processing as necessary.
Delay is controlled by three values: minimum delay, maximum delay and current delay. Current delay always stays between minimum and maximum but is only exercised when burst value is at zero. It works like this:
begin()
decreases it by 1 down until it reaches zero begin()
delays executing if burst value is at zero success()
increases burst value by 1 up until a maximum is reached
begin()
call doubles the delay each time the burst value is zero (delay is increased after the delay itself) up until the maximum delay is reached. success()
call divides the current delay by two until it reaches minimum delay value. Thread safety
ErrorRateControl
class is not synchronized and cannot be used by more that one thread at the same time.
@author Baltic Amadeus, JSC
@author Antanas Kompanas
|
|