Renamed Reactor.scala to MessageHandling.scala
This commit is contained in:
parent
53e1fbe91f
commit
34bfaa04bc
1 changed files with 0 additions and 0 deletions
79
akka-core/src/main/scala/dispatch/MessageHandling.scala
Normal file
79
akka-core/src/main/scala/dispatch/MessageHandling.scala
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.dispatch
|
||||
|
||||
import java.util.List
|
||||
|
||||
import se.scalablesolutions.akka.util.{HashCode, Logging}
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
import org.multiverse.commitbarriers.CountDownCommitBarrier
|
||||
|
||||
final class MessageInvocation(val receiver: Actor,
|
||||
val message: Any,
|
||||
val replyTo : Option[Either[Actor,CompletableFuture[Any]]],
|
||||
val transactionSet: Option[CountDownCommitBarrier]) {
|
||||
if (receiver eq null) throw new IllegalArgumentException("receiver is null")
|
||||
|
||||
def invoke = receiver.invoke(this)
|
||||
|
||||
def send = receiver.dispatcher.dispatch(this)
|
||||
|
||||
override def hashCode(): Int = synchronized {
|
||||
var result = HashCode.SEED
|
||||
result = HashCode.hash(result, receiver)
|
||||
result = HashCode.hash(result, message.asInstanceOf[AnyRef])
|
||||
result
|
||||
}
|
||||
|
||||
override def equals(that: Any): Boolean = synchronized {
|
||||
that != null &&
|
||||
that.isInstanceOf[MessageInvocation] &&
|
||||
that.asInstanceOf[MessageInvocation].receiver == receiver &&
|
||||
that.asInstanceOf[MessageInvocation].message == message
|
||||
}
|
||||
|
||||
override def toString = synchronized {
|
||||
"MessageInvocation[" +
|
||||
"\n\tmessage = " + message +
|
||||
"\n\treceiver = " + receiver +
|
||||
"\n\treplyTo = " + replyTo +
|
||||
"\n\ttransactionSet = " + transactionSet +
|
||||
"\n]"
|
||||
}
|
||||
}
|
||||
|
||||
trait MessageQueue {
|
||||
def append(handle: MessageInvocation)
|
||||
}
|
||||
|
||||
trait MessageInvoker {
|
||||
def invoke(message: MessageInvocation)
|
||||
}
|
||||
|
||||
trait MessageDispatcher extends Logging {
|
||||
protected val references = new ConcurrentHashMap[String, Actor]
|
||||
def dispatch(invocation: MessageInvocation)
|
||||
def start
|
||||
def shutdown
|
||||
def register(actor: Actor) = references.put(actor.uuid, actor)
|
||||
def unregister(actor: Actor) = {
|
||||
references.remove(actor.uuid)
|
||||
if (canBeShutDown)
|
||||
shutdown // shut down in the dispatcher's references is zero
|
||||
}
|
||||
def canBeShutDown: Boolean = references.isEmpty
|
||||
def isShutdown: Boolean
|
||||
def usesActorMailbox : Boolean
|
||||
}
|
||||
|
||||
trait MessageDemultiplexer {
|
||||
def select
|
||||
def wakeUp
|
||||
def acquireSelectedInvocations: List[MessageInvocation]
|
||||
def releaseSelectedInvocations
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue