should I synchronize the deque or not
I have a deque with pointers inside in a C++ application. I know there are
two threads to access it.
Thread1 will add pointers from the back and Thread2 will process and
remove pointers from the front.
The Thread2 will wait until deque reach certain of amount, saying 10
items, and then start to process it. It will only loop and process 10
items at a time. In the meantime, Thread1 may still keep adding new items
into the deque.
I think it will be fine without synchronize the deque because Thread1 and
Thread2 are accessing different part of the deque. It is deque not vector.
So there is no case that the existing memory of the container will be
reallocated.
Am I right? if not, why (I want to know what I am missing)?
No comments:
Post a Comment