com.threerings.presents.server
Class PresentsInvoker

java.lang.Object
  extended by java.lang.Thread
      extended by com.samskivert.util.LoopingThread
          extended by com.samskivert.util.Invoker
              extended by com.threerings.presents.server.ReportingInvoker
                  extended by com.threerings.presents.server.PresentsInvoker
All Implemented Interfaces:
Lifecycle.BaseComponent, Lifecycle.ShutdownComponent, RunQueue, Runnable, Executor

public class PresentsInvoker
extends ReportingInvoker
implements Lifecycle.ShutdownComponent

Extends the generic Invoker and integrates it a bit more into the Presents system.


Nested Class Summary
protected  class PresentsInvoker.BlockingUnit
          Runs in an Invoker or the DObjectManager and blocks it until released by EmptyingUnit.
protected  class PresentsInvoker.EmptyingUnit
          This gets posted to this invoker over and over again until it, any interdependent invokers and the DObjectManager are all empty.
 
Nested classes/interfaces inherited from class com.threerings.presents.server.ReportingInvoker
ReportingInvoker.Stats
 
Nested classes/interfaces inherited from class com.samskivert.util.Invoker
Invoker.Unit, Invoker.UnitProfile
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Nested classes/interfaces inherited from interface com.samskivert.util.RunQueue
RunQueue.AsExecutor
 
Field Summary
protected  Object _checkMonitor
          Synchronizes between EmptyingUnit and its BlockingUnits when checking that all interdependent invokers are blocked.
protected  List<Invoker> _interdependentInvokers
          Invokers that may post to Presents and may be posted to by Presents.
protected  PresentsDObjectMgr _omgr
          The distributed object manager with which we interoperate.
protected  PresentsServer _server
          The server we're working for.
 
Fields inherited from class com.threerings.presents.server.ReportingInvoker
_current, _currentUnit, _currentUnitStart, _defrep, _profrep, _recent, _totalUnitsRun
 
Fields inherited from class com.samskivert.util.Invoker
_defaultLongThreshold, _profileBucketCount, _profileBucketWidth, _queue, _receiver, _shutdownRequested, _tracker, PERF_TRACK
 
Fields inherited from class com.samskivert.util.LoopingThread
_running
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.samskivert.util.RunQueue
AWT
 
Constructor Summary
PresentsInvoker(PresentsDObjectMgr omgr, Lifecycle cycle, ReportManager repmgr)
           
 
Method Summary
 void addInterdependentInvoker(Invoker invoker)
          Adds an invoker that may post to the PresentsInvoker and the DObjectManager and may be posted to by the PresentsInvoker and DObjectManager.
protected  void didShutdown()
           
 void postRunnableWhenEmpty(Runnable onEmpty)
          Posts the given runnable to this invoker when it, the DObjectManager and any interdependent invokers are all empty.
 void shutdown()
           
 
Methods inherited from class com.threerings.presents.server.ReportingInvoker
didInvokeUnit, getStats, willInvokeUnit
 
Methods inherited from class com.samskivert.util.Invoker
execute, getPendingUnits, isDispatchThread, iterate, postRunnable, postUnit, recordMetrics, setDefaultLongThreshold, setProfilingParameters, shutdownRequested
 
Methods inherited from class com.samskivert.util.LoopingThread
handleIterateFailure, isRunning, kick, run, willStart
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.samskivert.util.RunQueue
isRunning
 

Field Detail

_checkMonitor

protected Object _checkMonitor
Synchronizes between EmptyingUnit and its BlockingUnits when checking that all interdependent invokers are blocked.


_interdependentInvokers

protected List<Invoker> _interdependentInvokers
Invokers that may post to Presents and may be posted to by Presents.


_omgr

protected PresentsDObjectMgr _omgr
The distributed object manager with which we interoperate.


_server

@Inject
protected PresentsServer _server
The server we're working for.

Constructor Detail

PresentsInvoker

@Inject
public PresentsInvoker(PresentsDObjectMgr omgr,
                              Lifecycle cycle,
                              ReportManager repmgr)
Method Detail

addInterdependentInvoker

public void addInterdependentInvoker(Invoker invoker)
Adds an invoker that may post to the PresentsInvoker and the DObjectManager and may be posted to by the PresentsInvoker and DObjectManager. This invoker will be taken into consideration by postRunnableWhenEmpty(Runnable) and in waiting for invokers to empty out on shutdown.


postRunnableWhenEmpty

public void postRunnableWhenEmpty(Runnable onEmpty)
Posts the given runnable to this invoker when it, the DObjectManager and any interdependent invokers are all empty.


shutdown

public void shutdown()
Specified by:
shutdown in interface Lifecycle.ShutdownComponent
Overrides:
shutdown in class Invoker

didShutdown

protected void didShutdown()
Overrides:
didShutdown in class LoopingThread