MapSafeSeq - laforge49/Asynchronous-Functional-Programming GitHub Wiki

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

MapSafeSeqTest

Tutorial