summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2012-06-13 12:57:43 -0400
committerEric Milkie <milkie@10gen.com>2012-06-13 15:13:13 -0400
commit4383b3de114404a485d3ad91110ea0fbff2c7790 (patch)
tree6b15f5444f729ad2a9c5eb744825197707b71d27 /src
parent70546ba57409051eeef817304955a411f46b763b (diff)
downloadmongo-4383b3de114404a485d3ad91110ea0fbff2c7790.tar.gz
SERVER-5685 add peek method to threadsafe queue
Diffstat (limited to 'src')
-rw-r--r--src/mongo/util/queue.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/util/queue.h b/src/mongo/util/queue.h
index bc1bdf61c67..a91bf161d47 100644
--- a/src/mongo/util/queue.h
+++ b/src/mongo/util/queue.h
@@ -151,6 +151,17 @@ namespace mongo {
return true;
}
+ bool peek(T& t) {
+
+ scoped_lock l( _lock );
+ if (_queue.empty()) {
+ return false;
+ }
+
+ t = _queue.front();
+ return true;
+ }
+
private:
mutable mongo::mutex _lock;
std::queue<T> _queue;