Michael_Giagnocavo

Is it safe to cache and access RuleSets and RuleEngines from multiple threads I've done tests and everything seems to work OK (no exceptions, rules seem to execute fine). I ask because it's about an order of magnitude difference to spawn a new RuleEngine for each execution versus sharing one among threads. (Even higher to create new RuleSets...)

The docs have the standard "static = safe, instance = not safe" but I'm not sure if that's totally accurate... Any guidance for perf here would be helpful.


Thanks!

-Michael



Re: Windows Workflow Foundation Caching / thread safe access for RuleSet or RuleEngine

Jurgen Willis

I assume that you mean that a given thread executes a RuleEngine, returns it to the cache and then another thread picks up the RuleEngine and executes it, correct In other words, you are only trying to execute a given RuleEngine instance on a single thread at a single point in time There shouldn't be any issues with this approach.




Re: Windows Workflow Foundation Caching / thread safe access for RuleSet or RuleEngine

Michael_Giagnocavo

Well I tried both ways and I haven't been able to repro any problems (versus, say, using the RuleParser, where I definately get exceptions when used concurrently). I was hoping that the RuleEngine was secretly threadsafe so I wouldn't have to use locks or an object pool...

-Michael





Re: Windows Workflow Foundation Caching / thread safe access for RuleSet or RuleEngine

Jurgen Willis

You should be OK even if two threads are executing the RuleEngine instance simultaneously.




Re: Windows Workflow Foundation Caching / thread safe access for RuleSet or RuleEngine

Michael_Giagnocavo

Sweet, that's great to know!

Thanks,

-Michael