summaryrefslogtreecommitdiff
path: root/src/mongo/db/service_context.h
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2020-09-29 21:59:56 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-02 01:52:40 +0000
commit9c5456e9d9efc288b8ac46820adc59ba58d1ea63 (patch)
tree8451126856966d7320750b800f937dca0f4fb157 /src/mongo/db/service_context.h
parent0e13f542973a557db3b2d1f6872a30e1d7dc23fd (diff)
downloadmongo-9c5456e9d9efc288b8ac46820adc59ba58d1ea63.tar.gz
SERVER-51165 SyncUnique Use atomic swap in setter, and AtomicWord<T*>
Diffstat (limited to 'src/mongo/db/service_context.h')
-rw-r--r--src/mongo/db/service_context.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h
index 7299d459190..f59d31ddd49 100644
--- a/src/mongo/db/service_context.h
+++ b/src/mongo/db/service_context.h
@@ -626,13 +626,11 @@ private:
}
void set(std::unique_ptr<T> p) {
- T* old = get();
- _ptr.store(reinterpret_cast<uintptr_t>(p.release()));
- delete old;
+ delete _ptr.swap(p.release());
}
T* get() const {
- return reinterpret_cast<T*>(_ptr.load());
+ return _ptr.load();
}
T* operator->() const {
@@ -648,7 +646,7 @@ private:
}
private:
- AtomicWord<uintptr_t> _ptr{0};
+ AtomicWord<T*> _ptr{nullptr};
};
class ClientObserverHolder {