After reading:
http://www.mail-archive.com/[email protected]/msg04691.html
the answer to a) and b) are pretty clear - sorry for the redundant
questions.
alan
> -----Original Message-----
> From: Alan Moore
> Sent: Thursday, September 19, 2002 2:15 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: JESS: How to pause rule firing?
>
>
> > 2) Have a rule that calls wait() on a well-known lock object when it
> > sees a "pause" fact. Here I'll use fetch to get it, but it could be
> > from a Java method, a static member, etc.
> >
> > (defrule pause
> > ?p <- (pause)
> > =>
> > (synchronized (fetch LOCK) ((fetch LOCK) wait))
> > (retract ?p))
> >
>
> This is good. Another variation would be to assert the pause
> fact with an
> external address of the lock object to wait on so you would have:
>
> (defrule pause
> ?p <- (pause ?resume)
> =>
> (synchronized ?resume (?resume wait))
> (retract ?p)
> )
>
> NB: I try to stay away from (store) and (fetch).
>
> This raises some questions that push my understanding of
> jess. If thread #1
> activates this rule and waits on the RHS, what happens if:
>
> a) other threads call run() or runUntilHalt()
>
> How can I guarantee that all possible threads will block? My
> current system
> doesn't have this scenario but I am just trying to understand
> how this could
> be generalized into a "complete engine pause", not just a
> single thread
> pause.
>
> b) other threads fire property change events matched by LHS patterns.
>
> I assume activations will be added/removed as necessary but
> no rules fire
> unless run() is called by another thread.
>
> > 3) When thread 2 wants thread 1 to pause, it uses
> >
> > rete.store("LOCK", wellKnownObject);
> > rete.assertString("(pause)");
> >
> > 4) To wake it up, #2 just says
> >
> > synchronized (wellKnownObject) {
> > wellKnownObject.notify();
> > }
> >
> > This doesn't seem to complicated to me -- what do you think?
>
> No, it is very simple. I just need some time to wrap my head
> around it. I'm
> sure I will be back with more questions once the fog lifts.
>
> Thanks for the help!
>
> alan
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users
> [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify
> [EMAIL PROTECTED]
> --------------------------------------------------------------------
>
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------