On Sat, Feb 22, 2014 at 1:49 PM, Miklos M.
[email protected] wrote:
Does copying a large pmt vector involve copying the underlying memory
region or do they share a single copy (refcounted)? If the do share a
single memory area, then can one thread modify the data of the vector
and will it be visible to the other thread just like regular arrays?
PMTs are always managed as a shared pointer (refcounted using
boost::intrusive_ptr). So yes, you have to be careful with thread
safety. PMTs are designed to be read-only to avoid the thread safety
issue (for instance, when adding a key:value pair to a dictionary, you
actually return a new PMT dictionary). The vectors are the only (and
don’t ask me why…) PMT type that is directly writable. So yes, be
careful about thread safety issues with this structure.