[kepler-dev] PN director and prefire/fire methods

Piotr Domagalski piotr.domagalski at fedstage.com
Tue Mar 17 13:09:13 PDT 2009


Hi all,

I'm using some actors implemented in Java along with PN director. They
are supposed to be fired only when there is data on all of their
connected input ports. Therefore, I use a prefire() that goes through
all input ports and uses hasToken() method.

But the general behavior is rather unexpected:

- once the prefire() method returns true (i.e. all connected ports
have a token pending)
- fire() uses get() to retrieve the tokens, do sth with them and send the output
- but then, even when there's actually no more tokens, hasToken() once
again returns true so the prefire() also returns true
- now we enter fire() but the first get() throws a TerminateProcessException

So my question is: why hasToken() returns true even though previous
fire() used get() and retrieved the one and only token in the channel?
I can live with the current behavior (I rethrow
TerminateProcessException from fire() or just let it go upwards) but
I'm interested how this should ideally be done.

Thanks for hints or general explanation why PN works that way.

-- 
Piotr Domagalski


More information about the Kepler-dev mailing list