Issue #1 - Make KillActorException lightweight/reusable

3 views
Skip to first unread message

Scott Pfister

unread,
Nov 13, 2009, 11:25:08 AM11/13/09
to actorom-discussions
I've been looking at the first issue as well, that optimizes the
throwing of KillActorException. Since it's effectively going to
require a singleton, thought to do something like this:

public class KillActorException extends RuntimeException {

private static final KillActorException coreException = new
KillActorException();

private KillActorException() {
}

public static void throwException() throws KillActorException {
throw coreException;
}

public Throwable fillInStackTrace() {
return null;
}
}

Thus, the usage would be: [KillActorException.throwException()] rather
than [throw new KillActorException()].

The overridden fillInStackTrace() method disables the filling of a
stack trace everytime this is thrown. Since this exception is used to
control the flow of the use of actors and can on occasion be used in
highly concurrent/performant situations, this should optimize that
aspect of Actorom's usage.

Thoughts?

--Scott

Sergio Bossa

unread,
Nov 13, 2009, 12:06:50 PM11/13/09
to actorom-d...@googlegroups.com
On Fri, Nov 13, 2009 at 5:25 PM, Scott Pfister <scott....@gmail.com> wrote:

> public class KillActorException extends RuntimeException {
>
>    private static final KillActorException coreException = new
> KillActorException();
>
>    private KillActorException() {
>    }
>
>    public static void throwException() throws KillActorException {
>        throw coreException;
>    }
>
>    public Throwable fillInStackTrace() {
>        return null;
>    }
> }
>
> Thus, the usage would be: [KillActorException.throwException()] rather
> than [throw new KillActorException()].

Very good.
Go for it ;)

--
Sergio Bossa
Software Passionate and Open Source Enthusiast.
URL: http://www.linkedin.com/in/sergiob
Reply all
Reply to author
Forward
0 new messages