Concurrent_Vector's push_back guarantees

Concurrent_Vector's push_back guarantees

What guarantee's does Concurrent_Vector's push_back have? If I push items onto it, will they be inserted in order (temporally)?

say:
time 0 time 1
thread1 : pushA
thread2 : pushB pushC

is there a guarantee that C will be placed after A, and B (A and B's order with respect to each other isn't important)
Or I could end up with B-C-A for example?

On a side note the comment in concurrent_vector.h on line 623 for the compact method is outdated
//! Optimize memory usage and fragmentation. Returns true if optimization occurred.
void compact();

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Quoting - robert.jay.gould
What guarantee's does Concurrent_Vector's push_back have? If I push items onto it, will they be inserted in order (temporally)?
say:
time 0 time 1
thread1 : pushA
thread2 : pushB pushC

is there a guarantee that C will be placed after A, and B (A and B's order with respect to each other isn't important)
Or I could end up with B-C-A for example?

It could end up with B-C-A unless you have a barrier between time 0 and time 1 (or tasks' relationship). So, without a synchronization of threads, the only guaranteed order is B-C.
But it's not guaranteed that they will have consecutive indexes since B-A-C is also possible. Such an assurance can be given by grow_by(2) call.

On a side note the comment in concurrent_vector.h on line 623 for the compact method is outdated
//! Optimize memory usage and fragmentation. Returns true if optimization occurred.
void compact();

Thanks, I'll fix it.

Leave a Comment

Please sign in to add a comment. Not a member? Join today