Awesome. It's exactly what I was looking for... and I feel like saying
"Well Duh!" and whacking myself on the back of the head for not thinking
of it.
Thanks for taking to the time to answer!
Philipp Haller wrote:
David Pollak wrote:
Is there a way to prioritize message handling in Actors... basically,
optionally drain all the "Foo" messages from the mailbox before
handling any other messages or in other ways "look ahead" into the
message queue?
Using `receiveWithin'/`reactWithin' you can do some kind of
look-ahead. The following function first removes all `Foo' messages
from the mailbox and then returns (note the timeout of 0 in
`receiveWithin'):
def drainFoo() {
receiveWithin(0) {
case Foo => drainFoo()
case TIMEOUT => // do nothing
}
}
Prioritizing can be done in general using
`receiveWithin'/`reactWithin'. Hope this helps.
Philipp