Respect the size of the forbidden queue

all

I am trying to use a non-blocking queue data structure.

#include <boost/thread/thread.hpp>
#include <boost/lockfree/queue.hpp>

      

However, I found that these data structures do not support methods for getting the number of current records they contain ( http://www.boost.org/doc/libs/1_53_0/doc/html/boost/lockfree/queue.html ).

What I want is similar to std :: queue :: size ( http://en.cppreference.com/w/cpp/container/queue/size ).

Thanks a lot for your help in advance!

+3


source to share


1 answer


If you just want to keep track of high / low water marks, use the atom counter, which you increment when you queue and decrement when you remove.

You can sample this counter periodically to perform any tuning / statistical analysis you may need.



The queue itself does not perform this operation because you only pay for what you need.

+4


source







All Articles