com.croftsoft.core.util.loop
Class WindowedLoopGovernor

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

public final class WindowedLoopGovernor
extends Object
implements LoopGovernor

Uses windowed averaging to estimate the target loop delay. The window size starts off small to grows to some maximum size. Any pause greater than one second will cause a window size reset.

Since:
2003-09-29
Version:
$Date: 2008/04/19 21:27:13 $
Author:
David Wallace Croft

Constructor Summary
WindowedLoopGovernor(double frequency)
          Convenience constructor.
WindowedLoopGovernor(long periodNanos, int maxWindowSize, long resetTimeNanos)
          Main constructor.
 
Method Summary
 void govern()
          This method puts the Thread to sleep for a limited time.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowedLoopGovernor

public WindowedLoopGovernor(long periodNanos,
                            int maxWindowSize,
                            long resetTimeNanos)
Main constructor.


WindowedLoopGovernor

public WindowedLoopGovernor(double frequency)
Convenience constructor.

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

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

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)