Reputation: 10745
I have an actor that receives messages in bunches--that is, it typically receives several messages in rapid succession, followed by long periods of inactivity. I would like to execute code when the actor hasn't received a message for, say, 250ms.
Just to clarify what I mean, in Javascript, I might write a bit of code like this:
function gotMessage() {
if(this.idleTimeout) {
clearTimeout(this.idleTimeout);
}
this.idleTimeout = setTimeout(function() {
//My code here
}, 250);
}
How might I achieve that effect in Scala, or in Akka if there's a mechanism for it already in that library?
Upvotes: 0
Views: 1368