-
Notifications
You must be signed in to change notification settings - Fork 1
MapSafeSeq
laforge49 edited this page Aug 25, 2011
·
4 revisions
MapSafeSeq is similar to MapSeq, except that it works with a Safe instance rather than a function, which means that other actors can be accessed while mapping a value.
Test code.
class MapSafe extends Safe {
override def func(target: Actor, msg: AnyRef, rf: Any => Unit)(implicit sender: ActiveActor) {
val kvPair = msg.asInstanceOf[KVPair[Int, Int]]
rf(kvPair.value * 2)
}
}
val transform = new MapSafeSeq[Int, Int, Int](Range(0, 3), new MapSafe)
Future(transform, Loop((key: Int, value: Int) => println(key + " " + value)))
Output.
0 0
1 2
2 4