I have a buffer using a std list container.
A worker is pushing elements on one side, and another thread is popping from the other side. Both these threads are using a mutex before accessing the container.
As a way to see the performance, I need to query the container for its size. But querying for size using a mutex seem like overkill, if not necessary.
Question is, is it necessary?
Documentation says on calling size() (under section Data Races: No contained elements are accessed: concurrently accessing or modifying them is safe.