What is the difference in using a loop instead of while (true) when using a trick with participants. Loop seems to be much faster, but why, and what happens under the hood?
Is there anything bad to using a loop instead of while (true)?
More about the context. I run performance tests as part of simple ping / pong code. And I use receipt.
This is the Ping class:
class ReceivePing( count : Int, pong : Actor ) extends Actor {def act() { var pingsLeft = count - 1 pong ! Start pong ! ReceivePing while(true) { receive { case ReceivePong => if (pingsLeft % 10000 == 0) Console.println("ReceivePing: pong") if (pingsLeft > 0) { pong ! ReceivePing pingsLeft -= 1 } else { Console.println("ReceivePing: stop") pong ! Stop exit() } } }}}
instead of while (true) it works better with a loop.
thanks
Zerdush
source share