Re: JESS: How do I determine Jess engine has finished firing rules
while there are activated rules and halt is false, fire a rule is also known as Rete.run(). wait for halt to become true or there to be new activations is also known as Rete.waitForActivations(). The complete source for runUntilHalt() is something like int runUntilHalt() throws JessException { int count = 0; do { count += run(); synchronized (getActivationSemaphore()) { if (isHalted()) break; waitForActivations(); if (isHalted()) break; } } while (true); return count; } All the Rete methods used here are public. Note that most Jess licenses include the full source code. On Feb 13, 2007, at 9:52 AM, Shi Paul wrote: Hi Ernest, You're so close to give me the right solution :-). Could you show me the code as while there are activated rules? I don't think it's Rete.listActivations().hasMore() since you mentioned in some other posts that it's not for internal use, so I'd like to see what you use internally so that I can apply the same theory. Thanks, Paul From: Ernest Friedman-Hill [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 19:33:10 -0700 As soon as you have more than one thread, you have to be *very careful* with your definitions of words like when and finished. The method runUntilHalt() just does something like this while (!halt) { while there are activated rules and halt is false fire a rule wait for halt to become true or there to be new activations } So when you call runUntilHalt(), Jess can potentially be done lots of times. If you want to do something special at that time, then don't call runUntilHalt() -- write your own equivalent method which is based on the same loop, but does something special. For example while (!halt) { while there are activated rules and halt is false fire a rule // At this point, either there are no rules to fire, or halt has been called // This is, I think, what you're calling a safe spot to call halt, although, of course, // it's always safe to do so if (mySpecialHaltFlag) break; wait for halt to become true or there to be new activations } On Feb 12, 2007, at 7:44 AM, Shi Paul wrote: Hi Henrique and others, Ernest's reply is only good for single thread execution, while I have at least 2 threads running. It's kinda like reproducer/ consumer scenario. I have Jess running in its own thread (consumer thread), I have my other threads running as facts- collecting threads (producer thread). So once those facts- collecting threads stop running, I need to stop Jess thread but the problem is when I call Rete.halt() I don't know if it's still busy. I tried Rete.listActivations() before stopping it, it seems doesn't work as well (the test result revealed that). I didn't try Scott's suggestion since I want the solution in the API level instead of adding a new rule in the knowledge base as I think the solution shouldn't be across 2 different domains. Does anybody has othe good suggestions? Thanks, Paul From: Henrique Lopes Cardoso [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 09:43:05 + Why don't you use Rete.run() instead of runUntilHalt() and wait for the method to return? Read Ernest's reply. Cheers, Henrique Shi Paul wrote: Hmmm, I wouldn't say it's a nice solution although it might work. I looked through the Rete api, there is a Rete.listActivations, I'm wondering if I could count on that, before calling rete.halt in the main thread, I'd use that API in a while loop and let main thread sleep for a few seconds if that doesn't return 0. From: Krasnigor, Scott L (N-AST) [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: RE: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 09 Feb 2007 15:59:11 -0500 The easiest thing to do is add a rule with a low salience (I use -1000) that will always match and add whatever action on the rhs that you want to use to signal all rules are done being processed. This rule will always be added to the end of the agenda, so when it fires, you know there are no more rules waiting to be fired. -Original Message- From: [EMAIL PROTECTED] [mailto:owner-jess- [EMAIL PROTECTED] On Behalf Of Shi Paul Sent: Friday, February 09, 2007 1:46 PM To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Hi, Actually I have created its own thread and then in that thread I call rete.runUntilHalt. Then I run into this issue just
Re: JESS: How do I determine Jess engine has finished firing rules
I actually went so far as to write a JessManager class that interfaces JESS with my application. It is a class that owns and runs a Rete engine when needed. It provides functions to add and remove Java objects as facts. It listens to the objects propertyChanges to be notified of changes. It has a separate thread that runs the Rete engine as necessary. The thread usually sleeps but is notified as soon as a fact was changed. Why not just call runUntilHalt()? Because this way, I can add flags telling whether a run is in progress and a monitor to wait for the run to stop. With the same monitor I can start and end something like a transaction to do changes to my facts while JESS is not running. This way I can add multiple related facts without JESS interfering by firing rules at the same time. It also has a startup and shutdown procedure. Unfortunately my JessManager has many dependencies with the rest of the application so that it would require some work to make it standalone and useable it in a different application. For instance, it can only add facts that are subclasses of the generic data object class of my application. But while writing that class, I was wondering if there wasn't or shouldn't be something like that in JESS. The ability to tell JESS: I am going to do some changes but wait before you start firing or please stop firing any new rule until I tell you or tell me when you have no more rule to fire is in my opinion very valuable. Regards, Florian Fischer Shi Paul wrote: Hi Henrique and others, Ernest's reply is only good for single thread execution, while I have at least 2 threads running. It's kinda like reproducer/consumer scenario. I have Jess running in its own thread (consumer thread), I have my other threads running as facts-collecting threads (producer thread). So once those facts-collecting threads stop running, I need to stop Jess thread but the problem is when I call Rete.halt() I don't know if it's still busy. I tried Rete.listActivations() before stopping it, it seems doesn't work as well (the test result revealed that). I didn't try Scott's suggestion since I want the solution in the API level instead of adding a new rule in the knowledge base as I think the solution shouldn't be across 2 different domains. Does anybody has othe good suggestions? Thanks, Paul From: Henrique Lopes Cardoso [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 09:43:05 + Why don't you use Rete.run() instead of runUntilHalt() and wait for the method to return? Read Ernest's reply. Cheers, Henrique Shi Paul wrote: Hmmm, I wouldn't say it's a nice solution although it might work. I looked through the Rete api, there is a Rete.listActivations, I'm wondering if I could count on that, before calling rete.halt in the main thread, I'd use that API in a while loop and let main thread sleep for a few seconds if that doesn't return 0. From: Krasnigor, Scott L (N-AST) [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: RE: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 09 Feb 2007 15:59:11 -0500 The easiest thing to do is add a rule with a low salience (I use -1000) that will always match and add whatever action on the rhs that you want to use to signal all rules are done being processed. This rule will always be added to the end of the agenda, so when it fires, you know there are no more rules waiting to be fired. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shi Paul Sent: Friday, February 09, 2007 1:46 PM To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Hi, Actually I have created its own thread and then in that thread I call rete.runUntilHalt. Then I run into this issue just mentioned, can you give me some more specifics about the solution as how to determin if the engine is not busy and can safely be stopped? I'd imagine that the main thread could just wait on some semaphore the jess thread operates or call into some API which does the same thing. Thanks, Paul From: Ernest Friedman-Hill [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 9 Feb 2007 13:19:29 -0500 On Feb 9, 2007, at 12:15 PM, Shi Paul wrote: Hi there, Is there an API to determine the rule engine has completed its work. I'd like to call rete.halt() to stop the engine, but I'm wondering what if the engine is still firing rules when I call that. Can anybody shed some lights on it? Jess doesn't create any threads on its own. If you call rete.run(), then run() returns when, and only when, there are no more rules to fire. If you have multiple threads, then you can set
Re: JESS: How do I determine Jess engine has finished firing rules
Hi Ernest, You're so close to give me the right solution :-). Could you show me the code as while there are activated rules? I don't think it's Rete.listActivations().hasMore() since you mentioned in some other posts that it's not for internal use, so I'd like to see what you use internally so that I can apply the same theory. Thanks, Paul From: Ernest Friedman-Hill [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 19:33:10 -0700 As soon as you have more than one thread, you have to be *very careful* with your definitions of words like when and finished. The method runUntilHalt() just does something like this while (!halt) { while there are activated rules and halt is false fire a rule wait for halt to become true or there to be new activations } So when you call runUntilHalt(), Jess can potentially be done lots of times. If you want to do something special at that time, then don't call runUntilHalt() -- write your own equivalent method which is based on the same loop, but does something special. For example while (!halt) { while there are activated rules and halt is false fire a rule // At this point, either there are no rules to fire, or halt has been called // This is, I think, what you're calling a safe spot to call halt, although, of course, // it's always safe to do so if (mySpecialHaltFlag) break; wait for halt to become true or there to be new activations } On Feb 12, 2007, at 7:44 AM, Shi Paul wrote: Hi Henrique and others, Ernest's reply is only good for single thread execution, while I have at least 2 threads running. It's kinda like reproducer/ consumer scenario. I have Jess running in its own thread (consumer thread), I have my other threads running as facts-collecting threads (producer thread). So once those facts-collecting threads stop running, I need to stop Jess thread but the problem is when I call Rete.halt() I don't know if it's still busy. I tried Rete.listActivations() before stopping it, it seems doesn't work as well (the test result revealed that). I didn't try Scott's suggestion since I want the solution in the API level instead of adding a new rule in the knowledge base as I think the solution shouldn't be across 2 different domains. Does anybody has othe good suggestions? Thanks, Paul From: Henrique Lopes Cardoso [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 09:43:05 + Why don't you use Rete.run() instead of runUntilHalt() and wait for the method to return? Read Ernest's reply. Cheers, Henrique Shi Paul wrote: Hmmm, I wouldn't say it's a nice solution although it might work. I looked through the Rete api, there is a Rete.listActivations, I'm wondering if I could count on that, before calling rete.halt in the main thread, I'd use that API in a while loop and let main thread sleep for a few seconds if that doesn't return 0. From: Krasnigor, Scott L (N-AST) [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: RE: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 09 Feb 2007 15:59:11 -0500 The easiest thing to do is add a rule with a low salience (I use -1000) that will always match and add whatever action on the rhs that you want to use to signal all rules are done being processed. This rule will always be added to the end of the agenda, so when it fires, you know there are no more rules waiting to be fired. -Original Message- From: [EMAIL PROTECTED] [mailto:owner-jess- [EMAIL PROTECTED] On Behalf Of Shi Paul Sent: Friday, February 09, 2007 1:46 PM To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Hi, Actually I have created its own thread and then in that thread I call rete.runUntilHalt. Then I run into this issue just mentioned, can you give me some more specifics about the solution as how to determin if the engine is not busy and can safely be stopped? I'd imagine that the main thread could just wait on some semaphore the jess thread operates or call into some API which does the same thing. Thanks, Paul From: Ernest Friedman-Hill [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 9 Feb 2007 13:19:29 -0500 On Feb 9, 2007, at 12:15 PM, Shi Paul wrote: Hi there, Is there an API to determine the rule engine has completed its work. I'd like to call rete.halt() to stop the engine, but I'm wondering what if the engine is still firing rules when I call that. Can anybody shed some lights on it? Jess doesn't create any threads
Re: JESS: How do I determine Jess engine has finished firing rules
Hi Florian, The ability to tell JESS: I am going to do some changes but wait before you start firing or please stop firing any new rule until I tell you or tell me when you have no more rule to fire is in my opinion very valuable. Totally agreed. It's not that apparent or inconvenient for user to implement these logic. BTW, if you don't mind, could you send your copy of JessManager to me so that I can study it a bit. I don't need all those details since I just need a skeleton to understand how you did that. Thanks! Paul From: Florian Fischer [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Tue, 13 Feb 2007 14:15:54 +0100 I actually went so far as to write a JessManager class that interfaces JESS with my application. It is a class that owns and runs a Rete engine when needed. It provides functions to add and remove Java objects as facts. It listens to the objects propertyChanges to be notified of changes. It has a separate thread that runs the Rete engine as necessary. The thread usually sleeps but is notified as soon as a fact was changed. Why not just call runUntilHalt()? Because this way, I can add flags telling whether a run is in progress and a monitor to wait for the run to stop. With the same monitor I can start and end something like a transaction to do changes to my facts while JESS is not running. This way I can add multiple related facts without JESS interfering by firing rules at the same time. It also has a startup and shutdown procedure. Unfortunately my JessManager has many dependencies with the rest of the application so that it would require some work to make it standalone and useable it in a different application. For instance, it can only add facts that are subclasses of the generic data object class of my application. But while writing that class, I was wondering if there wasn't or shouldn't be something like that in JESS. The ability to tell JESS: I am going to do some changes but wait before you start firing or please stop firing any new rule until I tell you or tell me when you have no more rule to fire is in my opinion very valuable. Regards, Florian Fischer Shi Paul wrote: Hi Henrique and others, Ernest's reply is only good for single thread execution, while I have at least 2 threads running. It's kinda like reproducer/consumer scenario. I have Jess running in its own thread (consumer thread), I have my other threads running as facts-collecting threads (producer thread). So once those facts-collecting threads stop running, I need to stop Jess thread but the problem is when I call Rete.halt() I don't know if it's still busy. I tried Rete.listActivations() before stopping it, it seems doesn't work as well (the test result revealed that). I didn't try Scott's suggestion since I want the solution in the API level instead of adding a new rule in the knowledge base as I think the solution shouldn't be across 2 different domains. Does anybody has othe good suggestions? Thanks, Paul From: Henrique Lopes Cardoso [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 09:43:05 + Why don't you use Rete.run() instead of runUntilHalt() and wait for the method to return? Read Ernest's reply. Cheers, Henrique Shi Paul wrote: Hmmm, I wouldn't say it's a nice solution although it might work. I looked through the Rete api, there is a Rete.listActivations, I'm wondering if I could count on that, before calling rete.halt in the main thread, I'd use that API in a while loop and let main thread sleep for a few seconds if that doesn't return 0. From: Krasnigor, Scott L (N-AST) [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: RE: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 09 Feb 2007 15:59:11 -0500 The easiest thing to do is add a rule with a low salience (I use -1000) that will always match and add whatever action on the rhs that you want to use to signal all rules are done being processed. This rule will always be added to the end of the agenda, so when it fires, you know there are no more rules waiting to be fired. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shi Paul Sent: Friday, February 09, 2007 1:46 PM To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Hi, Actually I have created its own thread and then in that thread I call rete.runUntilHalt. Then I run into this issue just mentioned, can you give me some more specifics about the solution as how to determin if the engine is not busy and can safely be stopped? I'd imagine that the main thread could just wait on some semaphore the jess thread operates or call into some API
Re: JESS: How do I determine Jess engine has finished firing rules
Hi Henrique and others, Ernest's reply is only good for single thread execution, while I have at least 2 threads running. It's kinda like reproducer/consumer scenario. I have Jess running in its own thread (consumer thread), I have my other threads running as facts-collecting threads (producer thread). So once those facts-collecting threads stop running, I need to stop Jess thread but the problem is when I call Rete.halt() I don't know if it's still busy. I tried Rete.listActivations() before stopping it, it seems doesn't work as well (the test result revealed that). I didn't try Scott's suggestion since I want the solution in the API level instead of adding a new rule in the knowledge base as I think the solution shouldn't be across 2 different domains. Does anybody has othe good suggestions? Thanks, Paul From: Henrique Lopes Cardoso [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 09:43:05 + Why don't you use Rete.run() instead of runUntilHalt() and wait for the method to return? Read Ernest's reply. Cheers, Henrique Shi Paul wrote: Hmmm, I wouldn't say it's a nice solution although it might work. I looked through the Rete api, there is a Rete.listActivations, I'm wondering if I could count on that, before calling rete.halt in the main thread, I'd use that API in a while loop and let main thread sleep for a few seconds if that doesn't return 0. From: Krasnigor, Scott L (N-AST) [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: RE: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 09 Feb 2007 15:59:11 -0500 The easiest thing to do is add a rule with a low salience (I use -1000) that will always match and add whatever action on the rhs that you want to use to signal all rules are done being processed. This rule will always be added to the end of the agenda, so when it fires, you know there are no more rules waiting to be fired. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shi Paul Sent: Friday, February 09, 2007 1:46 PM To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Hi, Actually I have created its own thread and then in that thread I call rete.runUntilHalt. Then I run into this issue just mentioned, can you give me some more specifics about the solution as how to determin if the engine is not busy and can safely be stopped? I'd imagine that the main thread could just wait on some semaphore the jess thread operates or call into some API which does the same thing. Thanks, Paul From: Ernest Friedman-Hill [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 9 Feb 2007 13:19:29 -0500 On Feb 9, 2007, at 12:15 PM, Shi Paul wrote: Hi there, Is there an API to determine the rule engine has completed its work. I'd like to call rete.halt() to stop the engine, but I'm wondering what if the engine is still firing rules when I call that. Can anybody shed some lights on it? Jess doesn't create any threads on its own. If you call rete.run(), then run() returns when, and only when, there are no more rules to fire. If you have multiple threads, then you can set up your own notification scheme based on that. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://www.jessrules.com 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] _ Your Space. Your Friends. Your Stories. Share your world with Windows Live Spaces. http://discoverspaces.live.com/?loc=en-CA 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]
Re: JESS: How do I determine Jess engine has finished firing rules
As soon as you have more than one thread, you have to be *very careful* with your definitions of words like when and finished. The method runUntilHalt() just does something like this while (!halt) { while there are activated rules and halt is false fire a rule wait for halt to become true or there to be new activations } So when you call runUntilHalt(), Jess can potentially be done lots of times. If you want to do something special at that time, then don't call runUntilHalt() -- write your own equivalent method which is based on the same loop, but does something special. For example while (!halt) { while there are activated rules and halt is false fire a rule // At this point, either there are no rules to fire, or halt has been called // This is, I think, what you're calling a safe spot to call halt, although, of course, // it's always safe to do so if (mySpecialHaltFlag) break; wait for halt to become true or there to be new activations } On Feb 12, 2007, at 7:44 AM, Shi Paul wrote: Hi Henrique and others, Ernest's reply is only good for single thread execution, while I have at least 2 threads running. It's kinda like reproducer/ consumer scenario. I have Jess running in its own thread (consumer thread), I have my other threads running as facts-collecting threads (producer thread). So once those facts-collecting threads stop running, I need to stop Jess thread but the problem is when I call Rete.halt() I don't know if it's still busy. I tried Rete.listActivations() before stopping it, it seems doesn't work as well (the test result revealed that). I didn't try Scott's suggestion since I want the solution in the API level instead of adding a new rule in the knowledge base as I think the solution shouldn't be across 2 different domains. Does anybody has othe good suggestions? Thanks, Paul From: Henrique Lopes Cardoso [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Mon, 12 Feb 2007 09:43:05 + Why don't you use Rete.run() instead of runUntilHalt() and wait for the method to return? Read Ernest's reply. Cheers, Henrique Shi Paul wrote: Hmmm, I wouldn't say it's a nice solution although it might work. I looked through the Rete api, there is a Rete.listActivations, I'm wondering if I could count on that, before calling rete.halt in the main thread, I'd use that API in a while loop and let main thread sleep for a few seconds if that doesn't return 0. From: Krasnigor, Scott L (N-AST) [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: RE: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 09 Feb 2007 15:59:11 -0500 The easiest thing to do is add a rule with a low salience (I use -1000) that will always match and add whatever action on the rhs that you want to use to signal all rules are done being processed. This rule will always be added to the end of the agenda, so when it fires, you know there are no more rules waiting to be fired. -Original Message- From: [EMAIL PROTECTED] [mailto:owner-jess- [EMAIL PROTECTED] On Behalf Of Shi Paul Sent: Friday, February 09, 2007 1:46 PM To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Hi, Actually I have created its own thread and then in that thread I call rete.runUntilHalt. Then I run into this issue just mentioned, can you give me some more specifics about the solution as how to determin if the engine is not busy and can safely be stopped? I'd imagine that the main thread could just wait on some semaphore the jess thread operates or call into some API which does the same thing. Thanks, Paul From: Ernest Friedman-Hill [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 9 Feb 2007 13:19:29 -0500 On Feb 9, 2007, at 12:15 PM, Shi Paul wrote: Hi there, Is there an API to determine the rule engine has completed its work. I'd like to call rete.halt() to stop the engine, but I'm wondering what if the engine is still firing rules when I call that. Can anybody shed some lights on it? Jess doesn't create any threads on its own. If you call rete.run (), then run() returns when, and only when, there are no more rules to fire. If you have multiple threads, then you can set up your own notification scheme based on that. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://www.jessrules.com
Re: JESS: How do I determine Jess engine has finished firing rules
On Feb 9, 2007, at 12:15 PM, Shi Paul wrote: Hi there, Is there an API to determine the rule engine has completed its work. I'd like to call rete.halt() to stop the engine, but I'm wondering what if the engine is still firing rules when I call that. Can anybody shed some lights on it? Jess doesn't create any threads on its own. If you call rete.run(), then run() returns when, and only when, there are no more rules to fire. If you have multiple threads, then you can set up your own notification scheme based on that. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://www.jessrules.com 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]
RE: JESS: How do I determine Jess engine has finished firing rules
The easiest thing to do is add a rule with a low salience (I use -1000) that will always match and add whatever action on the rhs that you want to use to signal all rules are done being processed. This rule will always be added to the end of the agenda, so when it fires, you know there are no more rules waiting to be fired. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shi Paul Sent: Friday, February 09, 2007 1:46 PM To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Hi, Actually I have created its own thread and then in that thread I call rete.runUntilHalt. Then I run into this issue just mentioned, can you give me some more specifics about the solution as how to determin if the engine is not busy and can safely be stopped? I'd imagine that the main thread could just wait on some semaphore the jess thread operates or call into some API which does the same thing. Thanks, Paul From: Ernest Friedman-Hill [EMAIL PROTECTED] Reply-To: jess-users@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: How do I determine Jess engine has finished firing rules Date: Fri, 9 Feb 2007 13:19:29 -0500 On Feb 9, 2007, at 12:15 PM, Shi Paul wrote: Hi there, Is there an API to determine the rule engine has completed its work. I'd like to call rete.halt() to stop the engine, but I'm wondering what if the engine is still firing rules when I call that. Can anybody shed some lights on it? Jess doesn't create any threads on its own. If you call rete.run(), then run() returns when, and only when, there are no more rules to fire. If you have multiple threads, then you can set up your own notification scheme based on that. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://www.jessrules.com 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] _ http://local.live.com/default.aspx?v=2cp=43.658648~-79.383962style=rl vl=15tilt=-90dir=0alt=-1000scene=3702663cid=7ABE80D1746919B4!1329 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]