I am working on a project in C++ that uses self created maps to store data - maps in this sense would be more like a "geographical" map, so an image. There are different threads reading from and writing to it. The data of a map is stored in an std vector of vectors of integers. Its size does not change, only the content of certain pixels through getter and setter functions.
My problem is the following: Sometimes everything works just fine, but more often I get corrupted images, in the sense that the value of a pixel changes sign or become completely different from what they should be. Could this be an issue of the threaded read/write access to the pixels, if so what should I use instead of the standard vectors? I have tried using mutex to ensure that only one thread reads or writes to the vector, however these read/write operations happen so often, that the application becomes too slow if I lock the vector at every operation.