EmptySeq - laforge49/Asynchronous-Functional-Programming GitHub Wiki

The empty sequence actor is both handy to have and easy to implement. Here's the code.

class EmptySeq
  extends Sequence {
  def first(msg: AnyRef, rf: Any => Unit) {
    rf(null)
  }

  def current(msg: AnyRef, rf: Any => Unit) {
    rf(null)
  }

  def next(msg: AnyRef, rf: Any => Unit) {
    rf(null)
  }
}

The empty sequence has no state, so it is an immutable actor which usually operates synchronously.

Here's the test code.

val emptySeq = new EmptySeq
println(Future(emptySeq, First()))
println(Future(emptySeq, Current(3)))
println(Future(emptySeq, Next("abc")))

And the output.

null
null
null

TestEmpty

Tutorial