Does anyone have a good technique for pausing rule firing? I tried to search the archives but the search function is broken at the moment...
Here is my setup and requirements: 1) thread #1 calls runUntilHalt() in order to keep the engine running. The intent is to call halt() only when the system is being shut down. 2) thread #2 needs to pause and then later resume rule firing. My initial plan was to have thread #2 assert a fact, e.g. (Pause), that the rules will check for with a (not (Pause)) pattern to make sure they don't fire when this fact is present. Later, thread #2 will assert a fact, e.g. (Resume), that will trigger a rule to retract the (Pause) fact. I don't like this approach since it clutters the rules with what is otherwise an external "pause" aspect. As part of doing this, thread #2 needs to ensure that the rules have stopped firing. The only way I could think of doing this is to call run() from thread #2. However, I am not sure this will guarantee no more rules are (still?) running on thread #1. Another approach would be to have thread #2 call halt() and then in thread #1, check a barrier/latch set/unset by thread #2 indicating that thread #1 should wait until thread #2 signals it to go back and call runUntilHalt(). I don't like this approach because thread #1 and thread #2 are from different parts of my system and I don't want to couple them any more tightly than they already are. Yet another idea is to switch the engine's focus to a module that does nothing but I'm not sure how to make this work since I have never used modules. All of this sounds very convoluted and was wondering if anyone on the list had any ideas about how to do this a better way. *Enhancement request* - would it be possible for the Rete class to implement pause()/resume() methods *or* for the (halt) command and/or the halt() method to take an (optional) parameter that would be returned to the thread(s) that have called runUntilHalt()? I know there is a public method on Rete called getActivationSemaphore() but I am not exactly sure how I should use this without breaking the agenda or causing some kind of deadlock. Any advise in this regard is appreciated. Thanks in advance. 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] --------------------------------------------------------------------
