Considering a lock based concurrent vector which is based on std::vector and locking a mutex for each call of std::vector public member function, how to iterate thread safely through the concurrent vector using range based for loop? in other terms, how to make iterate_thread in this example thread safe?
- Should I add a getter function in ConcurrentVector to return a copy of the std::vector?
- or add a for_each function that takes lambda?