I would like to create a system that loads options in ptree from an XML-file and fills this ptree with multiple Thread sofer, I have a simple class nude, which is accessible for every thread, in which the methods (IDs) and mills () Unfortunately, ptree does not look threadsof, so the program crashes a lot, is there any way to create country threadsof? Or is there a better solution together?
You can use the patron template described structural interactive.
 In fact, instead of a plain  ptree  instead of a  guardian .  mutex  with its data. The only way to access the data is through a  guardian_lock , which will be < Code> mutex 
  Parents & lt; Ptree & gt; Xml; // thread 1 {guardian_lock & lt; Ptree & gt; (Xml) lock; Lock-> Put ("a", "b"); } // thread 2 {guardian_lock & lt; Ptree & gt; (Xml) lock; Lock-> Put ("c", "d"); }    As you can only access the internal  ptree  through the lock, and lock the locked mute, you will never have a running position . 
Comments
Post a Comment