diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-11-11 01:30:02 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-11-11 01:30:02 -0500 |
commit | 1a499bf7dcb6b74e6f1ff98e0936683cb773924b (patch) | |
tree | 241591bcce16561819cb26bd813f41c05c630274 /bson | |
parent | 483db509ab777168e9e7b635ba93d90c29489039 (diff) | |
download | mongo-1a499bf7dcb6b74e6f1ff98e0936683cb773924b.tar.gz |
add zero() and clean AtomicUInt
Diffstat (limited to 'bson')
-rw-r--r-- | bson/util/atomic_int.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bson/util/atomic_int.h b/bson/util/atomic_int.h index f4d2749dc2d..d8169da740e 100644 --- a/bson/util/atomic_int.h +++ b/bson/util/atomic_int.h @@ -27,14 +27,18 @@ namespace mongo { struct AtomicUInt{ AtomicUInt() : x(0) {} AtomicUInt(unsigned z) : x(z) { } - volatile unsigned x; - operator unsigned() const { - return x; - } + + operator unsigned() const { return x; } + unsigned get() const { return x; } + inline AtomicUInt operator++(); // ++prefix inline AtomicUInt operator++(int);// postfix++ inline AtomicUInt operator--(); // --prefix inline AtomicUInt operator--(int); // postfix-- + + inline void zero() { x = 0; } // TODO: this isn't thread safe + + volatile unsigned x; }; #if defined(_WIN32) |