Remove DequeBasedMessageQueue.enqueueAllFirst

This commit is contained in:
Philipp Haller 2012-02-19 23:13:56 +01:00
parent 3604592e41
commit bda8617526
3 changed files with 3 additions and 13 deletions

View file

@ -20,7 +20,6 @@ object ActorWithBoundedStashSpec {
stash() stash()
sender ! "OK" sender ! "OK"
case "world" case "world"
self ! "world"
try { try {
unstashAll() unstashAll()
} catch { } catch {
@ -60,7 +59,7 @@ object ActorWithBoundedStashSpec {
""") """)
// bounded deque-based mailbox with capacity 10 // bounded deque-based mailbox with capacity 10
class Bounded(config: Config) extends BoundedDequeBasedMailbox(10, 10 seconds) class Bounded(config: Config) extends BoundedDequeBasedMailbox(10, 5 seconds)
} }
@ -80,7 +79,7 @@ class ActorWithBoundedStashSpec extends AkkaSpec(ActorWithBoundedStashSpec.testC
ActorWithBoundedStashSpec.expectedException = new TestLatch ActorWithBoundedStashSpec.expectedException = new TestLatch
val stasher = system.actorOf(Props(new StashingActor)) val stasher = system.actorOf(Props(new StashingActor))
// fill up stash // fill up stash
val futures = for (_ 1 to 10) yield { stasher ? "hello" } val futures = for (_ 1 to 11) yield { stasher ? "hello" }
futures foreach { Await.ready(_, 10 seconds) } futures foreach { Await.ready(_, 10 seconds) }
// cause unstashAll with capacity violation // cause unstashAll with capacity violation

View file

@ -98,7 +98,7 @@ An (unbounded) deque-based mailbox can be configured as follows:
*/ */
def unstashAll(): Unit = { def unstashAll(): Unit = {
try { try {
mailbox.enqueueAllFirst(self, theStash.reverseIterator, theStash.size) for (msg theStash.reverseIterator) mailbox.enqueueFirst(self, msg)
} finally { } finally {
theStash = Vector.empty[Envelope] theStash = Vector.empty[Envelope]
} }

View file

@ -335,7 +335,6 @@ trait BoundedMessageQueueSemantics extends QueueBasedMessageQueue {
trait DequeBasedMessageQueue extends QueueBasedMessageQueue { trait DequeBasedMessageQueue extends QueueBasedMessageQueue {
def queue: Deque[Envelope] def queue: Deque[Envelope]
def enqueueFirst(receiver: ActorRef, handle: Envelope): Unit def enqueueFirst(receiver: ActorRef, handle: Envelope): Unit
def enqueueAllFirst(receiver: ActorRef, handleIterator: Iterator[Envelope], size: Int): Unit
} }
trait UnboundedDequeBasedMessageQueueSemantics extends DequeBasedMessageQueue { trait UnboundedDequeBasedMessageQueueSemantics extends DequeBasedMessageQueue {
@ -343,9 +342,6 @@ trait UnboundedDequeBasedMessageQueueSemantics extends DequeBasedMessageQueue {
final def enqueueFirst(receiver: ActorRef, handle: Envelope): Unit = queue addFirst handle final def enqueueFirst(receiver: ActorRef, handle: Envelope): Unit = queue addFirst handle
final def enqueueAllFirst(receiver: ActorRef, handleIterator: Iterator[Envelope], size: Int): Unit =
handleIterator foreach { enqueueFirst(receiver, _) }
final def dequeue(): Envelope = queue.poll() final def dequeue(): Envelope = queue.poll()
} }
@ -367,11 +363,6 @@ trait BoundedDequeBasedMessageQueueSemantics extends DequeBasedMessageQueue {
} }
else queue putFirst handle else queue putFirst handle
final def enqueueAllFirst(receiver: ActorRef, handleIterator: Iterator[Envelope], size: Int): Unit =
if (queue.asInstanceOf[BlockingQueue[Envelope]].remainingCapacity >= size)
handleIterator foreach { enqueueFirst(receiver, _) }
else throw new MessageQueueAppendFailedException("Couldn't enqueue stash to " + receiver)
final def dequeue(): Envelope = queue.poll() final def dequeue(): Envelope = queue.poll()
} }