fix CallingThreadMailbox.numberOfMessages
This commit is contained in:
parent
e9a6c16bdc
commit
ca9d6b369d
2 changed files with 18 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue