Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] Concurrent vector assignment
From: Stefan Küppers (kueppers_web_at_[hidden])
Date: 2011-12-29 17:16:08


Hello David,
check if the implementation of the "vector"-class used by you is
thread-safe or not.
If not, you are responsible to asure the correct usage of the vector in
a multi-threaded environment.
Potential problems are all modifications of member variables of the
vector class, for example
if two threads resize the vector simultaneously.
Regards,
Stefan.

Am 26.12.2011 12:38, schrieb David White:
> 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 mailing list
> threads-devel_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/threads-devel


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