Boost logo

Boost Users :

Subject: Re: [Boost-users] Query regarding interest in my submitting plf::colony to Boost
From: Colin Humphries (colin_at_[hidden])
Date: 2015-07-16 06:03:48


> 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



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net