diff options
author | Scott Hernandez <scotthernandez@gmail.com> | 2013-01-29 14:36:24 -0500 |
---|---|---|
committer | Scott Hernandez <scotthernandez@gmail.com> | 2013-01-29 14:36:24 -0500 |
commit | 84df92e10e2458cd4ff3751c620535aa9f9a92b6 (patch) | |
tree | 19dbeaf69bcb26891f379c21a47743394ce956a5 /src/mongo/util/queue.h | |
parent | e9fe81f1d7eef251a9ebee4514031657372cf939 (diff) | |
download | mongo-84df92e10e2458cd4ff3751c620535aa9f9a92b6.tar.gz |
SERVER-8203: replication metrics
Diffstat (limited to 'src/mongo/util/queue.h')
-rw-r--r-- | src/mongo/util/queue.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/mongo/util/queue.h b/src/mongo/util/queue.h index 49ff3d27d32..0b0bd9403ad 100644 --- a/src/mongo/util/queue.h +++ b/src/mongo/util/queue.h @@ -34,9 +34,9 @@ namespace mongo { } /** - * Simple blocking queue with optional max size. - * A custom sizing function can optionally be given. By default, size is calculated as - * _queue.size(). + * Simple blocking queue with optional max size (by count or custom sizing function). + * A custom sizing function can optionally be given. By default the getSize function + * returns 1 for each item, resulting in size equaling the number of items queued. */ template<typename T> class BlockingQueue : boost::noncopyable { @@ -74,11 +74,29 @@ namespace mongo { return _queue.empty(); } + /** + * The size as measured by the size function. Default to counting each item + */ size_t size() const { scoped_lock l( _lock ); return _currentSize; } + /** + * The max size for this queue + */ + size_t maxSize() const { + return _maxSize; + } + + /** + * The number/count of items in the queue ( _queue.size() ) + */ + int count() const { + scoped_lock l( _lock ); + return _queue.size(); + } + void clear() { scoped_lock l(_lock); _queue = std::queue<T>(); |