|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.echomine.net.SimpleConnectionThrottler
public class SimpleConnectionThrottler
This throttler simply throttles the rate by checking to see if the rate is above the rate limit, and if it is, sleep occurs so that the rate is decreased (since rate is calculated as data transferred over a period of time). The throttling algorithm is to simply sleep and wait for the next checkup. Sleep interval will actually double each time a checkup occurs and the rate is above the limit. Sleep interval will get reset once rate goes below the limit. The problem with this throttler is that if the remote client is sending at an extremely high speed, you will get a massively long interval which may not be what you want.
Also make sure that you don't use this for global throttling. This class is not multi-thread safe and must not be used as a such (ie. controlling throttling limited to a global transfer rate averaged across all the uploads).
Constructor Summary | |
---|---|
SimpleConnectionThrottler(int bps_in)
Constructor that accepts the rate limit in KBytes/sec. |
Method Summary | |
---|---|
int |
getBPS()
|
void |
setBPS(int bps_in)
|
void |
throttle(ConnectionModel cmodel)
Throttles the data transfer rate based on the information provided by the connection model. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleConnectionThrottler(int bps_in)
Method Detail |
---|
public void throttle(ConnectionModel cmodel)
ConnectionThrottler
throttle
in interface ConnectionThrottler
public int getBPS()
public void setBPS(int bps_in)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |