renamed DurableMailboxType to DurableMailbox

This commit is contained in:
Jonas Bonér 2010-11-30 11:51:23 +01:00
parent 37998f202a
commit dd5d761959
4 changed files with 14 additions and 14 deletions

View file

@ -106,7 +106,7 @@ class ExecutorBasedEventDrivenDispatcher(
override def mailboxSize(actorRef: ActorRef) = getMailbox(actorRef).size override def mailboxSize(actorRef: ActorRef) = getMailbox(actorRef).size
def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailboxType): AnyRef = mailboxType match { def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailbox): AnyRef = mailboxType match {
case UnboundedMailbox(blocking) => new DefaultUnboundedMessageQueue(blocking) with ExecutableMailbox { case UnboundedMailbox(blocking) => new DefaultUnboundedMessageQueue(blocking) with ExecutableMailbox {
def dispatcher = ExecutorBasedEventDrivenDispatcher.this def dispatcher = ExecutorBasedEventDrivenDispatcher.this
} }
@ -120,7 +120,7 @@ class ExecutorBasedEventDrivenDispatcher(
/** /**
* Creates and returns a durable mailbox for the given actor. * Creates and returns a durable mailbox for the given actor.
*/ */
private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailboxType): AnyRef = private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailbox): AnyRef =
createMailbox(mailboxType.mailboxImplClassname, actorRef) createMailbox(mailboxType.mailboxImplClassname, actorRef)
private[akka] def start = log.slf4j.debug("Starting up {}\n\twith throughput [{}]", this, throughput) private[akka] def start = log.slf4j.debug("Starting up {}\n\twith throughput [{}]", this, throughput)

View file

@ -194,7 +194,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(
override val toString = "ExecutorBasedEventDrivenWorkStealingDispatcher[" + name + "]" override val toString = "ExecutorBasedEventDrivenWorkStealingDispatcher[" + name + "]"
private[akka] def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailboxType): AnyRef = mailboxType match { private[akka] def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailbox): AnyRef = mailboxType match {
case UnboundedMailbox(blocking) => // FIXME make use of 'blocking' in work stealer ConcurrentLinkedDeque case UnboundedMailbox(blocking) => // FIXME make use of 'blocking' in work stealer ConcurrentLinkedDeque
new ConcurrentLinkedDeque[MessageInvocation] with MessageQueue with Runnable { new ConcurrentLinkedDeque[MessageInvocation] with MessageQueue with Runnable {
def enqueue(handle: MessageInvocation): Unit = this.add(handle) def enqueue(handle: MessageInvocation): Unit = this.add(handle)
@ -224,7 +224,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(
/** /**
* Creates and returns a durable mailbox for the given actor. * Creates and returns a durable mailbox for the given actor.
*/ */
private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailboxType): AnyRef = private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailbox): AnyRef =
createMailbox(mailboxType.mailboxImplClassname, actorRef) createMailbox(mailboxType.mailboxImplClassname, actorRef)
private[akka] override def register(actorRef: ActorRef) = { private[akka] override def register(actorRef: ActorRef) = {

View file

@ -166,12 +166,12 @@ class HawtDispatcher(val aggregate: Boolean = true, val parent: DispatchQueue =
def suspend(actorRef: ActorRef) = mailbox(actorRef).suspend def suspend(actorRef: ActorRef) = mailbox(actorRef).suspend
def resume(actorRef:ActorRef) = mailbox(actorRef).resume def resume(actorRef:ActorRef) = mailbox(actorRef).resume
private[akka] def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailboxType): AnyRef = null.asInstanceOf[AnyRef] private[akka] def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailbox): AnyRef = null.asInstanceOf[AnyRef]
/** /**
* Creates and returns a durable mailbox for the given actor. * Creates and returns a durable mailbox for the given actor.
*/ */
private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailboxType): AnyRef = null.asInstanceOf[AnyRef] private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailbox): AnyRef = null.asInstanceOf[AnyRef]
override def toString = "HawtDispatcher" override def toString = "HawtDispatcher"
} }

View file

@ -31,17 +31,17 @@ trait MessageQueue {
*/ */
sealed trait MailboxType sealed trait MailboxType
abstract class TransientMailboxType(val blocking: Boolean = false) extends MailboxType abstract class TransientMailbox(val blocking: Boolean = false) extends MailboxType
case class UnboundedMailbox(block: Boolean = false) extends TransientMailboxType(block) case class UnboundedMailbox(block: Boolean = false) extends TransientMailbox(block)
case class BoundedMailbox( case class BoundedMailbox(
block: Boolean = false, block: Boolean = false,
val capacity: Int = { if (Dispatchers.MAILBOX_CAPACITY < 0) Int.MaxValue else Dispatchers.MAILBOX_CAPACITY }, val capacity: Int = { if (Dispatchers.MAILBOX_CAPACITY < 0) Int.MaxValue else Dispatchers.MAILBOX_CAPACITY },
val pushTimeOut: Duration = Dispatchers.MAILBOX_PUSH_TIME_OUT) extends TransientMailboxType(block) { val pushTimeOut: Duration = Dispatchers.MAILBOX_PUSH_TIME_OUT) extends TransientMailbox(block) {
if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative") if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative")
if (pushTimeOut eq null) throw new IllegalArgumentException("The push time-out for BoundedMailbox can not be null") if (pushTimeOut eq null) throw new IllegalArgumentException("The push time-out for BoundedMailbox can not be null")
} }
case class DurableMailboxType(mailboxImplClassname: String) extends MailboxType case class DurableMailbox(mailboxImplClassname: String) extends MailboxType
class DefaultUnboundedMessageQueue(blockDequeue: Boolean) class DefaultUnboundedMessageQueue(blockDequeue: Boolean)
extends LinkedBlockingQueue[MessageInvocation] with MessageQueue { extends LinkedBlockingQueue[MessageInvocation] with MessageQueue {
@ -83,17 +83,17 @@ trait MailboxFactory {
*/ */
private[akka] def createMailbox(actorRef: ActorRef): AnyRef = private[akka] def createMailbox(actorRef: ActorRef): AnyRef =
mailboxType.getOrElse(throw new IllegalStateException("No mailbox type defined")) match { mailboxType.getOrElse(throw new IllegalStateException("No mailbox type defined")) match {
case mb: TransientMailboxType => createTransientMailbox(actorRef, mb) case mb: TransientMailbox => createTransientMailbox(actorRef, mb)
case mb: DurableMailboxType => createDurableMailbox(actorRef, mb) case mb: DurableMailbox => createDurableMailbox(actorRef, mb)
} }
/** /**
* Creates and returns a transient mailbox for the given actor. * Creates and returns a transient mailbox for the given actor.
*/ */
private[akka] def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailboxType): AnyRef private[akka] def createTransientMailbox(actorRef: ActorRef, mailboxType: TransientMailbox): AnyRef
/** /**
* Creates and returns a durable mailbox for the given actor. * Creates and returns a durable mailbox for the given actor.
*/ */
private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailboxType): AnyRef private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailbox): AnyRef
} }