Fork me on GitHub
#clara
<
2019-10-08
>
Eduardo Mata16:10:50

I have a multi-threaded parallel synchronous processor using Clara rules. How can I make sure that for every Rule session is clear out for the following session?

jjttjj16:10:25

@contact904 I'm still really new to Clara, but sessions are immutable, so you should be able to make a session and then use that as the starting session from any number of parallel threads without worrying. Is the work each thread does independent of all others? Or does there need to be some coordination?

Eduardo Mata16:10:33

The threads are independent of each other, but some of them use the same rules.clj module

jjttjj16:10:40

Ok then yeah that's perfect, you should be able to bind mk-session somewhere, and then use it from any number of threads and the threads will only see the starting point. (Someone correct me if I'm wrong :)

Eduardo Mata16:10:39

So if I have a set of N threads and the N thread are independent of each other running in parallel. All these N threads are using the same rules.clj module. I should not worry because the threads getting facts from other threads as they are only aware of the session the thread created at the time?

jjttjj16:10:05

Yes, that is my understanding

ethanc16:10:28

The rule definitions should be separate from the memory of the sessions that are created.

jjttjj16:10:02

you can even share a "root" session because they are immutable, in the same way a bunch of threads can operate on the same root vector in clojure and only see their version of it

ethanc16:10:49

jjttjj is correct, assuming that all threads were loading the same rules

Eduardo Mata17:10:18

Correct me if I am wrong. So I have multiple rules, I inserted a collection of events into the current session in progress. My main record is called Event. I will insert-all the Records in to the session and fire the rules. A little of back story, I used to have an atom, now I am inserting facts in to a new Record called NewEvents. Back to the current situation, The first rule will create a side effect (modify) on the Record and insert it in to NewEvents. The following rules will be fired with the Record Event, if it fits the rule, I want to look in to the past modified record in NewEvents and apply the changes to the corresponding NewEvent. I tried retract but it didn't seem to work. If I retract the fact from NewEvent, then apply changes, I insert it back but then it is not there anymore 😞. Using insert-unconditional! just makes it eat my available heap space

Eduardo Mata18:10:01

basically, the question would be: How do I modify a NewEvent?