diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-06-04 17:23:43 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-06-04 23:41:32 -0400 |
commit | 78f183186136b8271af4ec253e4bcb2bf0bbdbac (patch) | |
tree | 8de0821d35fd3847302c017af213b9e4403a95f2 /src/mongo/platform | |
parent | 20ddcb42a39673f8be73e4555390a417aaa047e3 (diff) | |
download | mongo-78f183186136b8271af4ec253e4bcb2bf0bbdbac.tar.gz |
added AtomicUInt64::fetchAndAdd
Diffstat (limited to 'src/mongo/platform')
-rw-r--r-- | src/mongo/platform/atomic_uint64.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/platform/atomic_uint64.h b/src/mongo/platform/atomic_uint64.h index a9ec18757bf..ac910f9690c 100644 --- a/src/mongo/platform/atomic_uint64.h +++ b/src/mongo/platform/atomic_uint64.h @@ -37,6 +37,7 @@ namespace mongo { inline void set(unsigned long long newValue); inline void add(unsigned long long by ); + inline unsigned long long fetchAndAdd( unsigned long long by = 1 ); AtomicUInt64& operator+=( unsigned long long by ){ add( by ); return *this; } inline void zero() { set(0); } @@ -62,6 +63,13 @@ namespace mongo { boost::mutex::scoped_lock lk( _mutex ); _counter += by; } + + inline unsigned long long AtomicUInt64::fetchAndAdd(unsigned long long by) { + boost::mutex::scoped_lock lk( _mutex ); + unsigned long long old = _counter; + _counter += by; + return old; + } } |