I want to construct at least hundreds of environments from an existing environment of clips, and then run these concurrently in multi threads.
Dose clips support this function (eg. deep copy construct)? Or how can I implement these features?
I apply the sourcecore of clips in my c++ project. Now I have a string that contains many rules.If I want to execute multiple requests simultaneously,I have to call the create method multiple times, but this time is too expensive for me to create so many same env.
I use the c code of clips. Below is my creation process:
std::unique_ptr<void> CreateClips(const string &rules) {
std::unique_ptr<void> clips(CreateEnvironment());
if (!clips) {
throw runtime_error("[FATAL] clips CreateEnvironment() failed");
}
int retcode;
retcode = ClipsEnvLoadFromString(clips.get(), rules);
if (retcode != 1) {
throw runtime_error("[FATAL] clips EvnLoadFromString() failed, " +
rules);
}
return clips;
}
There is no deep copy functionality. If you save your rules in a binary format using the bsave function, you can load them much more quickly using the bload function. The speedup increases as the number of constructs in the binary image increases. For a system with around 30 rules I see a speedup of around 9 times faster and for a system with around 660 rules I see a speedup of around 47 times faster.