mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 20:43:57 +00:00
thread_local.cc: Reset: use exchange instead of load+store
This commit is contained in:
parent
446cebde3a
commit
f1874abfba
|
@ -392,7 +392,7 @@ void ThreadLocalPtr::StaticMeta::Reset(uint32_t id, void* ptr) {
|
||||||
MutexLock l(Mutex());
|
MutexLock l(Mutex());
|
||||||
tls->entries.resize(id + 1);
|
tls->entries.resize(id + 1);
|
||||||
}
|
}
|
||||||
void* oldptr = tls->entries[id].ptr.load(std::memory_order_acquire);
|
void* oldptr = tls->entries[id].ptr.exchange(ptr, std::memory_order_acq_rel);
|
||||||
if (UNLIKELY(nullptr != oldptr && ptr != oldptr)) {
|
if (UNLIKELY(nullptr != oldptr && ptr != oldptr)) {
|
||||||
auto inst = Instance();
|
auto inst = Instance();
|
||||||
MutexLock l(inst->MemberMutex());
|
MutexLock l(inst->MemberMutex());
|
||||||
|
@ -400,7 +400,6 @@ void ThreadLocalPtr::StaticMeta::Reset(uint32_t id, void* ptr) {
|
||||||
handler(oldptr);
|
handler(oldptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tls->entries[id].ptr.store(ptr, std::memory_order_release);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ThreadLocalPtr::StaticMeta::Swap(uint32_t id, void* ptr) {
|
void* ThreadLocalPtr::StaticMeta::Swap(uint32_t id, void* ptr) {
|
||||||
|
|
Loading…
Reference in a new issue