|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xnap.io.ThrottleSupport
public class ThrottleSupport
Provides a throttle implementation based on time ticks. Clients can allocate a limited amount of bytes for each tick. If all bandwidth has been allocated clients are stalled until the next tick.
Field Summary | |
---|---|
protected long |
allocated
|
protected long |
bandwidth
bytes per tick |
protected java.lang.Object |
lock
|
static long |
TICK_LENGTH
The default length of a tick. |
protected long |
tickStart
|
Constructor Summary | |
---|---|
ThrottleSupport()
|
Method Summary | |
---|---|
int |
allocate(int bytes)
Returns the number of bytes that the calling thread is allowed to send. |
int |
getPreferredBlocksize()
Returns the preferred block size each client should try to allocate at a time. |
void |
setBandwidth(long bandwidth)
Sets the maximum bandwidth. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long TICK_LENGTH
protected long bandwidth
protected long allocated
protected long tickStart
protected java.lang.Object lock
Constructor Detail |
---|
public ThrottleSupport()
Method Detail |
---|
public int getPreferredBlocksize()
allocate(int)
public void setBandwidth(long bandwidth)
bandwidth
- byte / spublic int allocate(int bytes)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |