com.croftsoft.core.util.loop
Class SamplerLoopGovernor

java.lang.Object
  extended by com.croftsoft.core.util.loop.SamplerLoopGovernor
All Implemented Interfaces:
LoopGovernor

public final class SamplerLoopGovernor
extends Object
implements LoopGovernor

Sets the delay by sampling the calling frequency over time.

Since:
2002-03-13
Version:
2003-05-22
Author:
David Wallace Croft

Field Summary
static long DEFAULT_AVERAGING_SAMPLES_MAX
           
static long DEFAULT_SAMPLE_PERIOD_NANOS
           
 
Constructor Summary
SamplerLoopGovernor(double frequency)
           
SamplerLoopGovernor(double frequency, Clock clock)
           
SamplerLoopGovernor(double frequency, long samplePeriodNanos, long averagingSamplesMax, Clock clock)
          Constructs a LoopGovernor with the specified target frequency.
 
Method Summary
 void govern()
          This method puts the Thread to sleep for a limited time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SAMPLE_PERIOD_NANOS

public static final long DEFAULT_SAMPLE_PERIOD_NANOS
See Also:
Constant Field Values

DEFAULT_AVERAGING_SAMPLES_MAX

public static final long DEFAULT_AVERAGING_SAMPLES_MAX
See Also:
Constant Field Values
Constructor Detail

SamplerLoopGovernor

public SamplerLoopGovernor(double frequency,
                           long samplePeriodNanos,
                           long averagingSamplesMax,
                           Clock clock)
Constructs a LoopGovernor with the specified target frequency.

Parameters:
frequency - The targeted loop frequency in loops per second.

SamplerLoopGovernor

public SamplerLoopGovernor(double frequency,
                           Clock clock)

SamplerLoopGovernor

public SamplerLoopGovernor(double frequency)
Method Detail

govern

public void govern()
            throws InterruptedException
Description copied from interface: LoopGovernor
This method puts the Thread to sleep for a limited time.

Specified by:
govern in interface LoopGovernor
Throws:
InterruptedException

CroftSoft Javadoc

CroftSoft Core Javadoc (2008-09-28 20:58:02)