diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-10-26 17:21:52 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-10-26 17:21:52 +0000 |
commit | 0b16c1266296e93339f56054f1b5e3f5908d3e55 (patch) | |
tree | f8c744d294678cc75f87eb13e2ffbcfd83a13851 /src/actors/scala/actors/MessageQueue.scala | |
parent | 180c140953263e11b3656652d6a2ac22c5c327d6 (diff) | |
download | scala-0b16c1266296e93339f56054f1b5e3f5908d3e55.tar.gz scala-0b16c1266296e93339f56054f1b5e3f5908d3e55.tar.bz2 scala-0b16c1266296e93339f56054f1b5e3f5908d3e55.zip |
First half of fix for #1518.
Diffstat (limited to 'src/actors/scala/actors/MessageQueue.scala')
-rw-r--r-- | src/actors/scala/actors/MessageQueue.scala | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/actors/scala/actors/MessageQueue.scala b/src/actors/scala/actors/MessageQueue.scala index 540a992640..469b24c1c1 100644 --- a/src/actors/scala/actors/MessageQueue.scala +++ b/src/actors/scala/actors/MessageQueue.scala @@ -92,30 +92,30 @@ class MessageQueue(protected val label: String) { /** Removes the n-th message that satisfies the predicate <code>p</code>. */ - def remove(n: Int)(p: Any => Boolean): Option[(Any, OutputChannel[Any])] = + def remove(n: Int)(p: (Any, OutputChannel[Any]) => Boolean): Option[(Any, OutputChannel[Any])] = removeInternal(n)(p) map (x => (x.msg, x.session)) /** Extracts the first message that satisfies the predicate <code>p</code> * or <code>null</code> if <code>p</code> fails for all of them. */ - def extractFirst(p: Any => Boolean): MessageQueueElement = + def extractFirst(p: (Any, OutputChannel[Any]) => Boolean): MessageQueueElement = removeInternal(0)(p) orNull - private def removeInternal(n: Int)(p: Any => Boolean): Option[MessageQueueElement] = { + private def removeInternal(n: Int)(p: (Any, OutputChannel[Any]) => Boolean): Option[MessageQueueElement] = { var pos = 0 def foundMsg(x: MessageQueueElement) = { changeSize(-1) Some(x) } - def test(msg: Any): Boolean = - p(msg) && (pos == n || { pos += 1 ; false }) + def test(msg: Any, session: OutputChannel[Any]): Boolean = + p(msg, session) && (pos == n || { pos += 1 ; false }) if (isEmpty) // early return return None // special handling if returning the head - if (test(first.msg)) { + if (test(first.msg, first.session)) { val res = first first = first.next if (res eq last) @@ -128,7 +128,7 @@ class MessageQueue(protected val label: String) { var prev = first while (curr != null) { - if (test(curr.msg)) { + if (test(curr.msg, curr.session)) { prev.next = curr.next if (curr eq last) last = prev @@ -161,12 +161,12 @@ private[actors] trait MessageQueueTracer extends MessageQueue printQueue("GET %s" format res) res } - override def remove(n: Int)(p: Any => Boolean): Option[(Any, OutputChannel[Any])] = { + override def remove(n: Int)(p: (Any, OutputChannel[Any]) => Boolean): Option[(Any, OutputChannel[Any])] = { val res = super.remove(n)(p) printQueue("REMOVE %s" format res) res } - override def extractFirst(p: Any => Boolean): MessageQueueElement = { + override def extractFirst(p: (Any, OutputChannel[Any]) => Boolean): MessageQueueElement = { val res = super.extractFirst(p) printQueue("EXTRACT_FIRST %s" format res) res |