java.lang.Object
org.praxislive.base.AbstractRoot.Controller
- All Implemented Interfaces:
Root.Controller
- Enclosing class:
AbstractRoot
Implementation of Root.Controller.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidawaitTermination(long timeout, TimeUnit unit) Wait for the Root to fully terminate, freeing up all resources.booleanisAlive()Query whether the Root is alive - has been started and has not been signalled to shutdown.protected voidCalled on receipt of aPacket(Call) or a Runnable task.voidshutdown()Signal the Root to be shutdown.voidStart the Root.booleansubmitPacket(Packet packet) Deliver a Packet to this Root.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.praxislive.core.Root.Controller
start
-
Constructor Details
-
Controller
protected Controller()
-
-
Method Details
-
submitPacket
Description copied from interface:Root.ControllerDeliver a Packet to this Root. This method is intended to be called from a thread other than the primary thread of the Root. It will add the packet to a queue and return immediately - this method will never block as it may be called from the thread of another Root.This method will return true if the Packet can be handled (see eg. BlockingQueue::offer)
- Specified by:
submitPacketin interfaceRoot.Controller- Parameters:
packet- message (see Packet / Call) to handle- Returns:
- true if the packet can be handled
-
start
Description copied from interface:Root.ControllerStart the Root. Controller implementations will ensure that this method can only be invoked once.The lookup may contain services that the root may utilise - eg. a shared
ScheduledExecutorService. This allows services to be controlled on a per-root basis, rather than relying on the hub lookup.- Specified by:
startin interfaceRoot.Controller- Parameters:
lookup- optional services for the root to use
-
shutdown
public void shutdown()Description copied from interface:Root.ControllerSignal the Root to be shutdown. This method is intended to be called asynchronously and will return immediately - it will not wait for the Root to actually complete execution.- Specified by:
shutdownin interfaceRoot.Controller
-
isAlive
public boolean isAlive()Description copied from interface:Root.ControllerQuery whether the Root is alive - has been started and has not been signalled to shutdown. This method may return false even if the Root is still in the process of termination. If the caller needs to know when the Root has finished termination, useRoot.Controller.awaitTermination(long, java.util.concurrent.TimeUnit).- Specified by:
isAlivein interfaceRoot.Controller- Returns:
- true if started and not signalled to shutdown
-
awaitTermination
public void awaitTermination(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException Description copied from interface:Root.ControllerWait for the Root to fully terminate, freeing up all resources.- Specified by:
awaitTerminationin interfaceRoot.Controller- Parameters:
timeout- maximum time to waitunit- unit of timeout- Throws:
InterruptedException- if the current thread is interruptedTimeoutException- if the timeout is reached before terminationExecutionException- if the termination is the result of an exception
-
onQueueReceipt
protected void onQueueReceipt()Called on receipt of aPacket(Call) or a Runnable task. The default implementation will callAbstractRoot.Delegate.onQueueReceipt()if a delegate is attached, or otherwise trigger an asynchronous poll of the queue.
-