fix CallingThreadMailbox.numberOfMessages

This commit is contained in:
Roland 2012-04-03 16:24:50 +02:00
parent e9a6c16bdc
commit ca9d6b369d
2 changed files with 18 additions and 1 deletions

View file

@ -46,9 +46,26 @@ private[akka] abstract class Mailbox(val actor: ActorCell, val messageQueue: Mes
import Mailbox._
/**
* Try to enqueue the message to this queue, or throw an exception.
*/
def enqueue(receiver: ActorRef, msg: Envelope): Unit = messageQueue.enqueue(receiver, msg)
/**
* Try to dequeue the next message from this queue, return null failing that.
*/
def dequeue(): Envelope = messageQueue.dequeue()
/**
* Indicates whether this queue is non-empty.
*/
def hasMessages: Boolean = messageQueue.hasMessages
/**
* Should return the current number of messages held in this queue; may
* always return 0 if no other value is available efficiently. Do not use
* this for testing for presence of messages, use `hasMessages` instead.
*/
def numberOfMessages: Int = messageQueue.numberOfMessages
@volatile

View file

@ -294,7 +294,7 @@ class CallingThreadMailbox(_receiver: ActorCell, val mailboxType: MailboxType) e
override def enqueue(receiver: ActorRef, msg: Envelope): Unit = throw new UnsupportedOperationException("CallingThreadMailbox cannot enqueue normally")
override def dequeue(): Envelope = throw new UnsupportedOperationException("CallingThreadMailbox cannot dequeue normally")
override def hasMessages: Boolean = q.get.q.hasMessages
override def numberOfMessages: Int = -1
override def numberOfMessages: Int = 0
def queue = q.get