Gang. First, a high-level description of the problem and approach.
I have a list containing images and pixel locations in each image - a list of lists. I want to select n elements at random from this list of images and for each image I want to iterate over k random pixel locations. I want to do this in parallel. For each processed pixel, I want to remove it from the list.
My approach is to distribute images and lists of pixels among all streams, so each stream has its own list of images and lists of pixel locations, but neither of the two streams will process the same image at the same time. I save them to vector.
So, let's say the code looks something like this:
struct MyObject
{
int imageIndex_;
std::list< Point > pixels_;
};
std::vector< std::list < MyObject > > mainList(NUM_THREADS);
It mainList[0]will then contain images processed by the stream with identifier 0. I start the streams as follows: #pragma omp parallel num_threads(numThreads_)and then they all start the same piece of code that randomly displays images from the list of image streams.
The problem is that when a pixel is processed and the stream erases it from the list of pixels, for example mainList[0].begin()->pixels_.erase(someIter), I sometimes get a statement; It tracks the delete statement.
, std:: list , , , . , , ( ) , , .
? ?