org.apache.qpid.junit.extensions
Class SleepThrottle

java.lang.Object
  extended by org.apache.qpid.junit.extensions.BaseThrottle
      extended by org.apache.qpid.junit.extensions.SleepThrottle
All Implemented Interfaces:
Throttle

public class SleepThrottle
extends BaseThrottle
implements Throttle

SleepThrottle is a Throttle implementation that generates short pauses using the thread sleep methods. As the pauses get shorter, this technique gets more innacurate. In practice, around 100 Hz is the cap rate for accuracy.

CRC Card
Responsibilities Collaborations
Accept throttling rate in operations per second.
Inject short pauses to fill out processing cycles to a specified rate.
Check against a throttle speed without waiting.


Field Summary
 
Fields inherited from class org.apache.qpid.junit.extensions.BaseThrottle
cycleTimeNanos, firstCall, firstCheckCall
 
Constructor Summary
SleepThrottle()
           
 
Method Summary
 void throttle()
          This method can only be called at the rate set by the BaseThrottle.setRate(float) method, if it is called faster than this it will inject short pauses to restrict the call rate to that rate.
 
Methods inherited from class org.apache.qpid.junit.extensions.BaseThrottle
checkThrottle, setRate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.qpid.junit.extensions.Throttle
checkThrottle, setRate
 

Constructor Detail

SleepThrottle

public SleepThrottle()
Method Detail

throttle

public void throttle()
This method can only be called at the rate set by the BaseThrottle.setRate(float) method, if it is called faster than this it will inject short pauses to restrict the call rate to that rate.

Specified by:
throttle in interface Throttle


Licensed to the Apache Software Foundation