The vectors aren't "pushed" into the shared memory. There is no implicit stack.
Instead, the vector lives in the shared memory. What you're reading is in fact the very same vector as in another process, at the very same time.
Note that this strongly implies that you need a shared mutex to synchronize access too, otherwise you'll have data races between the threads (from different processes) and by definition this is Undefined Behaviour in C++.
On a slightly different angle:
I do a
push_back
to the shared memory from the writing process. So the vectors are being pushed like a stack push into the shared memory, in LIFO order?
Breaking it down:
I do a
push_back
to the shared memoryNo you don't. You
push
a vector element to theback
of one vector. This vector is the single thing you shared, under the name"Vector_name"
So the vectors are being pushed
No, your vectors stay where they are: in shared memory.
like a stack push into the shared memory, in LIFO order?
No, there's only 1 vector. A vector is itself a ordered sequential container. It supports random access, so
for (auto it = v.begin(); it!= v.end(); ++it) { // process `*it` in order }
vs
for (auto it = v.rbegin(); it!= v.rend(); ++it) { // process `*it` in reversed order }
If you always use
push_back
to insert, thenin order
iteration is like "FIFO"