public static interface ThrottledByteSource.Curve
ThrottledByteSource
.
The throttling is based on a curve b(t). At time t, the total number of bytes served should not exceed b(t).
The unit of t is milli-second. t is relative to the 1st read, i.e. t=0 on the first read() call.
This interface uses long
type for b and t.
Both the caller and the implementer should be careful with arithmetic precisions.
Abstract Methods | |
---|---|
long |
b(long t)
The max total number of bytes that can be served at time t (ms).
|
long |
t(long b)
The inverse function of b(t).
|
Static Method | |
ThrottledByteSource.Curve |
linear(long b0,
long bytesPerSecond)
Create a linear curve.
|
long b(long t)
Required: if t1<=t2, then b(t1)<=b(t2)
long t(long b)
Required: t(b(x)) = x (approximately)
static ThrottledByteSource.Curve linear(long b0, long bytesPerSecond)
The curve will be b(t) = b0 + t * bytesPerSecond / 1000
CAUTION: the unit of `bytesPerSecond` is byte/second, not milli-second.