You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
laforge49 edited this page Jul 31, 2011
·
2 revisions
To loop through a sequence, send the Loop message to a sequence actor.
case class Loop[K, V](f: (K, V) => Unit)
The sequence actor will call the function in the Loop message for every key/value pair in the sequence and then return a result of null.
There are thread safety issues with passing a function to an actor, if the function references any mutable state of the sending actor, or if the function sends message to an actor.
Example.
val fact = new java.util.ArrayList[Int]
fact.add(0)
fact.add(1)
fact.add(2)
fact.add(6)
fact.add(24)
val factSeq = new ListSeq(fact)
Future(factSeq, Loop((key: Int, value: Int) => println(key+" "+value)))