Boost logo

Threads-Devel :

Subject: [Threads-devel] Concurrent vector assignment
From: David White (dawhite32_at_[hidden])
Date: 2011-12-26 06:38:43


Please forgive me if this has already been answered - I just couldn't seem to find hints anywhere.

I have a vector of objects which I would like to process concurrently. Through the use of a thread-safe queue, I can guarantee that only one thread will work on any one vector element at a time. Hence, each element is modified once by a single thread via iterators.

My question is - do I need a mutex and associated locking for this vector assignment behaviour? In other words, does each thread need to lock the vector before it can modify an element in which no other thread is interested in?

During this operation, no 'modifying' functions (e.g. push_back, pop_back, insert, erase, etc) are called.

Thanks in advance.

Kind regards, David.


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk