-
Notifications
You must be signed in to change notification settings - Fork 1
EmptySeq
laforge49 edited this page Jul 31, 2011
·
4 revisions
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 always 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