Added support hook for persistent mailboxes + cleanup and optimizations

This commit is contained in:
Viktor Klang 2010-09-01 16:33:56 +02:00
parent 021dd2d732
commit 9368ddc25d
8 changed files with 43 additions and 43 deletions

View file

@ -71,21 +71,41 @@ trait MessageQueue {
*/
trait MessageDispatcher extends Logging {
protected val uuids = new ConcurrentSkipListSet[String]
def dispatch(invocation: MessageInvocation)
def start
def shutdown
def register(actorRef: ActorRef) = uuids add actorRef.uuid
def register(actorRef: ActorRef) {
if(actorRef.mailbox eq null)
actorRef.mailbox = createMailbox(actorRef)
uuids add actorRef.uuid
}
def unregister(actorRef: ActorRef) = {
uuids remove actorRef.uuid
//actorRef.mailbox = null //FIXME should we null out the mailbox here?
if (canBeShutDown) shutdown // shut down in the dispatcher's references is zero
}
def canBeShutDown: Boolean = uuids.isEmpty
def isShutdown: Boolean
/**
* Returns the size of the mailbox for the specified actor
*/
def mailboxSize(actorRef: ActorRef):Int = 0
/**
* Creates and returns a mailbox for the given actor
*/
protected def createMailbox(actorRef: ActorRef): AnyRef = null
}
/**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
trait MessageDemultiplexer {
def select