Ah, right. Actually, if you don't rethrow the exception,
the thread won't terminate...

Edward


On 6/22/11 7:02 AM, Colin Enticott wrote:
It might be best to re-throw the exception in case the method is
expanded on. That is:

} catch (Exception e) {
    if (!(e instanceof TerminateProcessExeption)) {
       e.printStackTrace();
       throw new IllegalActionException(this, e, e.getMessage());
    }

    else

       throw e;
}


Colin

On 22 June 2011 23:23, Edward A. Lee <e...@eecs.berkeley.edu
<mailto:e...@eecs.berkeley.edu>> wrote:


    The offending lines are these:

                    } catch (Exception e) {
                            e.printStackTrace();
                            throw new
    IllegalActionException(e.__getMessage());
                    }


    The issue is that in PN, the fire() method is invoked in an infinite
    loop in its own thread. The get() method blocks until there is input
    available. When the PN director detects that there are no more
    tokens to process, it causes to get() to throw a
    TerminateProcessException.  It would not work for get() to just
    return, because then the infinite loop would continue and the thread
    would never terminate.

    You could change this to:

    } catch (Exception e) {
       if (!(e instanceof TerminateProcessExeption)) {
          e.printStackTrace();
          throw new IllegalActionException(e.__getMessage());
       }
    }

    Note further that it would be better to replace

          throw new IllegalActionException(e.__getMessage());

    with

          throw new IllegalActionException(this, e, e.getMessage());

    This will cause the offending actor to be highlighted, and the chain
    of exception stack traces to be shown. It makes it unnecessary to
    do this:

          e.printStackTrace();

    Edward




    On 6/22/11 1:07 AM, Vincenzo Forchi wrote:

        Hi Christopher,

        I think I'm doing some weird mistake, but I don't understand why the
        other actors I wrote work. Anyway, here's the (stripped down)
        actor that
        doesn't work and the model.

        Cheers,
        Vincenzo

        On 21/06/2011 17:32, Christopher Brooks wrote:

            Hi Vincenzo,
            Do you have a small test actor and sample model?

            _Christopher

            On 6/21/11 8:05 AM, Vincenzo Forchi wrote:

                Hi Edward,

                On 21/06/2011 16:53, Edward A. Lee wrote:

                    Something's fishy here.
                    Such a model should work fine in PN.
                    Note that hasToken() _alaways_ returns true in PN.

                That's good to know, I completely missed that

                    The get() method blocks when there is no input.

                Apparently in this case it doesn't, but why is the fire even
                triggered in the first place?

                    Looks like something is terminating the threads
                    using a TerminateProcessException. How is your model
                    supposed to be stopped?

                When all the tokens have been consumed, which works for
                most of my
                actors with the PN and for all
                of them with the DDF.

                Cheers,
                Vincenzo




    _______________________________________________
    Kepler-users mailing list
    Kepler-users@kepler-project.org <mailto:Kepler-users@kepler-project.org>
    http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users


<<attachment: eal.vcf>>

_______________________________________________
Kepler-users mailing list
Kepler-users@kepler-project.org
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

Reply via email to