2014-04-23 1:52 GMT+04:00 Sebastian Gesemann <s.gesemann@gmail.com>:
<...>
My guess is that "working" with an iterator while concurrently doing an
erase_first/resize creates a data race -- possibly because an iterator
tries to read some of circular_buffer's state which is modified via
erase_first and/or resize. But that's just a guess. I did not check the
circular_buffer implementation too closely.

You are right. Iterator holds a pointer to circular_buffer and accesses some of its internals.

However it is safe to use only iterators and overwrite independent parts of circular_buffer. All the operations with iterators do not modify internals of circular_bufer.
So if you change cb.erase_first(n)/cb.resize(cb.capacity()) to iterator operations there must be no problems. Though I thinks that's what you have done in case of custom vector-based data structure.

Thanks for the investigation!

--
Best regards,
Antony Polukhin