Changed Iterator to take immutable.Seq instead of mutable.Seq. Also changed Pi tutorial to use Vector instead of Array
This commit is contained in:
parent
d859a9cb13
commit
1eea91abfa
2 changed files with 5 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ package akka.routing
|
|||
|
||||
import akka.actor.ActorRef
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.immutable.Seq
|
||||
|
||||
/**
|
||||
* An Iterator that is either always empty or yields an infinite number of Ts.
|
||||
|
|
@ -18,7 +19,7 @@ trait InfiniteIterator[T] extends Iterator[T] {
|
|||
* CyclicIterator is a round-robin style InfiniteIterator that cycles the supplied List.
|
||||
*/
|
||||
case class CyclicIterator[T](val items: Seq[T]) extends InfiniteIterator[T] {
|
||||
def this(items: java.util.List[T]) = this(items.toSeq)
|
||||
def this(items: java.util.List[T]) = this(items.toList)
|
||||
|
||||
@volatile private[this] var current: Seq[T] = items
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ case class CyclicIterator[T](val items: Seq[T]) extends InfiniteIterator[T] {
|
|||
* useful for work-stealing.
|
||||
*/
|
||||
case class SmallestMailboxFirstIterator(val items : Seq[ActorRef]) extends InfiniteIterator[ActorRef] {
|
||||
def this(items: java.util.List[ActorRef]) = this(items.toSeq)
|
||||
def this(items: java.util.List[ActorRef]) = this(items.toList)
|
||||
def hasNext = items != Nil
|
||||
|
||||
def next = items.reduceLeft((a1, a2) => if (a1.mailboxSize < a2.mailboxSize) a1 else a2)
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ object Pi {
|
|||
|
||||
// create the workers
|
||||
val workers = {
|
||||
val ws = new Array[ActorRef](nrOfWorkers)
|
||||
for (i <- 0 until nrOfWorkers) ws(i) = actorOf[Worker].start
|
||||
var ws = Vector[ActorRef]()
|
||||
for (i <- 0 until nrOfWorkers) ws = ws :+ actorOf[Worker].start
|
||||
ws
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue