Changed *Iterator to take a Seq instead of a List

This commit is contained in:
Jonas Bonér 2011-04-01 14:29:26 +02:00
parent 8f4dcfe22a
commit 827c678b49
4 changed files with 8 additions and 17 deletions

View file

@ -6,15 +6,10 @@ package akka.actor
import akka.dispatch._
import akka.config.Config._
import akka.config.Supervision._
import akka.config.ConfigurationException
import akka.util.Helpers.{narrow, narrowSilently}
import akka.util.ListenerManagement
import akka.AkkaException
import java.util.concurrent.TimeUnit
import java.net.InetSocketAddress
import scala.reflect.BeanProperty
import akka.util. {ReflectiveAccess, Duration}
import akka.remoteinterface.RemoteSupport
@ -277,9 +272,6 @@ object Actor extends ListenerManagement {
* }
* </pre>
*
* <p/>
* The Actor trait also has a 'log' member field that can be used for logging within the Actor.
*
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
trait Actor {
@ -353,7 +345,7 @@ trait Actor {
* <p/>
* Example code:
* <pre>
* def receive = {
* def receive = {
* case Ping =&gt;
* println("got a 'Ping' message")
* self.reply("pong")

View file

@ -488,4 +488,4 @@ trait RemoteClientModule extends RemoteModule { self: RemoteModule =>
@deprecated("Will be removed after 1.1")
private[akka] def unregisterClientManagedActor(hostname: String, port: Int, uuid: Uuid): Unit
}
}

View file

@ -15,10 +15,10 @@ trait InfiniteIterator[T] extends Iterator[T]
/**
* CyclicIterator is a round-robin style InfiniteIterator that cycles the supplied List.
*/
class CyclicIterator[T](items: List[T]) extends InfiniteIterator[T] {
def this(items: java.util.List[T]) = this(items.toList)
case class CyclicIterator[T](items: Seq[T]) extends InfiniteIterator[T] {
def this(items: java.util.List[T]) = this(items.toSeq)
@volatile private[this] var current: List[T] = items
@volatile private[this] var current: Seq[T] = items
def hasNext = items != Nil
@ -36,8 +36,8 @@ class CyclicIterator[T](items: List[T]) extends InfiniteIterator[T] {
* This InfiniteIterator always returns the Actor that has the currently smallest mailbox
* useful for work-stealing.
*/
class SmallestMailboxFirstIterator(items : List[ActorRef]) extends InfiniteIterator[ActorRef] {
def this(items: java.util.List[ActorRef]) = this(items.toList)
case class SmallestMailboxFirstIterator(items : Seq[ActorRef]) extends InfiniteIterator[ActorRef] {
def this(items: java.util.List[ActorRef]) = this(items.toSeq)
def hasNext = items != Nil
def next = items.reduceLeft((a1, a2) => if (a1.mailboxSize < a2.mailboxSize) a1 else a2)

View file

@ -39,8 +39,7 @@ abstract class UntypedDispatcher extends UntypedActor {
@throws(classOf[Exception])
def onReceive(msg: Any): Unit = {
val r = route(msg)
if(r eq null)
throw new IllegalStateException("No route for " + msg + " defined!")
if (r eq null) throw new IllegalStateException("No route for " + msg + " defined!")
if (isSenderDefined) r.forward(transform(msg))(someSelf)
else r.!(transform(msg))(None)
}