c++ - How to get size of boost SPSC Queue? -
we know number of element in queue @ given point of time. pushing , popping objects, know number of object in queue buffer. there inbuilt function ? or other way ?
http://www.boost.org/doc/libs/1_53_0/doc/html/boost/lockfree/spsc_queue.html
you can't reliably size because invites race conditions. same reason, won't find empty()
method: time method returned value, irrelevant, because might have changed.
sometimes lockfree containers provide "unreliable_size()" method (for purposes of statistics/logging)
the special case here spsc assume single producer , consumers:
size_type read_available() const;
number of available elements can popped spsc_queue
size_type write_available() const;
get write space write elements
note these only valid when used respective consumer/producer thread.
Comments
Post a Comment