com.threerings.tudey.server.util
Class SceneTicker

java.lang.Object
  extended by com.threerings.tudey.server.util.SceneTicker
Direct Known Subclasses:
SceneTicker.DedicatedThread, SceneTicker.EventThread

public abstract class SceneTicker
extends Object

Ticks some number of scene managers.


Nested Class Summary
static class SceneTicker.DedicatedThread
          Ticks the scenes on a dedicated thread.
static class SceneTicker.EventThread
          Ticks the scenes on the event thread.
 
Field Summary
protected  int _actualInterval
          The average actual interval.
protected  TruncatedAverage _intervalAverage
          The trailing average of the actual intervals.
protected  boolean _lastLong
          Whether the last tick was considered "long."
protected  long _lastTick
          The time of the last tick.
protected  RunQueue _runQueue
          The event thread run queue.
protected  TudeySceneManager[] _sarray
          Holds the scene managers during processing.
protected  List<TudeySceneManager> _scenemgrs
          The list of scene managers to tick.
protected  int _targetInterval
          The target interval.
 
Constructor Summary
SceneTicker(RunQueue runQueue, int targetInterval)
          Creates a new scene ticker.
 
Method Summary
 void add(TudeySceneManager scenemgr)
          Adds a scene manager to be ticked.
 boolean contains(TudeySceneManager scenemgr)
          Checks whether the specified scene manager is being ticked.
 int getActualInterval()
          Returns the average actual interval.
 void remove(TudeySceneManager scenemgr)
          Removes a scene manager.
 void setTargetInterval(int interval)
          Sets the target interval.
protected abstract  void start()
          Starts ticking.
protected abstract  void stop()
          Stops ticking.
protected  long tick()
          Ticks the scene managers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_runQueue

protected RunQueue _runQueue
The event thread run queue.


_targetInterval

protected volatile int _targetInterval
The target interval.


_actualInterval

protected volatile int _actualInterval
The average actual interval.


_scenemgrs

protected List<TudeySceneManager> _scenemgrs
The list of scene managers to tick.


_sarray

protected TudeySceneManager[] _sarray
Holds the scene managers during processing.


_lastTick

protected long _lastTick
The time of the last tick.


_lastLong

protected boolean _lastLong
Whether the last tick was considered "long."


_intervalAverage

protected TruncatedAverage _intervalAverage
The trailing average of the actual intervals.

Constructor Detail

SceneTicker

public SceneTicker(RunQueue runQueue,
                   int targetInterval)
Creates a new scene ticker.

Method Detail

setTargetInterval

public void setTargetInterval(int interval)
Sets the target interval.


getActualInterval

public int getActualInterval()
Returns the average actual interval.


add

public void add(TudeySceneManager scenemgr)
Adds a scene manager to be ticked.


remove

public void remove(TudeySceneManager scenemgr)
Removes a scene manager.


contains

public boolean contains(TudeySceneManager scenemgr)
Checks whether the specified scene manager is being ticked.


start

protected abstract void start()
Starts ticking.


stop

protected abstract void stop()
Stops ticking.


tick

protected long tick()
Ticks the scene managers.