Re: [Boost-users] Query regarding interest in my submitting plf::colony to Boost
I don't think anything related to multithreading should be done by such kind of container.
Disturbed by that comment I just wanted to add for the benefit of anyone just starting out with multi-threading that in my experience containers are entirely safe for multi-threading PROVIDED that you're only reading from them (i.e. they are passed by const &). This is by far the most efficient way to pass common information into parallel threads (all threads read the same data). For containers required to return a result, the approach that works for me is to create a vector of containers and dedicate one to each thread. The result containers must be guaranteed to remain in scope until all threads have completed so I usually make them global. The only challenge is how to efficiently coalesce the partial results. Get this wrong (or use too many threads) and the performance gain from multi-threading quickly evaporates. Colin Humphries
Disturbed by that comment I just wanted to add for the benefit of anyone just starting out with multi-threading that in my experience containers are entirely safe for multi-threading PROVIDED that you’re only reading from them (i.e. they are passed by const &). This is by far the most
Hi Colin, it's okay, he's clarified his comment to mean that nothing needs to _change_ in the container to make it safe for multithreaded usage :)
participants (2)
-
Colin Humphries
-
Soul Studios