This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Actor start/restart

1 reply
Etam
Joined: 2011-05-29,
User offline. Last seen 42 years 45 weeks ago.
Hi,
how do you avoid this:
if (actor.getState == Actor.State.Terminated) actor.restartelse actor.start
Why you can not start an actor two times?
Thanks in advance,Etam.
Erik Engbrecht
Joined: 2008-12-19,
User offline. Last seen 3 years 18 weeks ago.
Re: Actor start/restart

I'd say that starting an actor and restarting an actor are sufficiently semantically different to justify different calls and an error if you try to do the wrong one.  You should generally know based on context whether it's the first time you are starting the actor, or if you are restarting it.  So doing one instead of the other in most circumstances would represent a bug.  That's not to say there aren't legitimate code structures where the same path handles starting and restarting.  I just think it would be the much less common case.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland