mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
fix(channel store): add acquire/release pair in fast update path (#2704)
This pointer is shared between threads and updated immediately, but the memory behind it is not synced.
This commit is contained in:
parent
292c5bcd71
commit
6df0fa4948
2 changed files with 4 additions and 4 deletions
|
@ -38,14 +38,14 @@ ChannelStore::UpdatablePointer::UpdatablePointer(const UpdatablePointer& other)
|
|||
}
|
||||
|
||||
ChannelStore::SubscribeMap* ChannelStore::UpdatablePointer::Get() const {
|
||||
return ptr.load(memory_order_relaxed);
|
||||
return ptr.load(memory_order_acquire); // sync pointed memory
|
||||
}
|
||||
|
||||
void ChannelStore::UpdatablePointer::Set(ChannelStore::SubscribeMap* sm) {
|
||||
ptr.store(sm, memory_order_relaxed);
|
||||
ptr.store(sm, memory_order_release); // sync pointed memory
|
||||
}
|
||||
|
||||
ChannelStore::SubscribeMap* ChannelStore::UpdatablePointer::operator->() {
|
||||
ChannelStore::SubscribeMap* ChannelStore::UpdatablePointer::operator->() const {
|
||||
return Get();
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class ChannelStore {
|
|||
SubscribeMap* Get() const;
|
||||
void Set(SubscribeMap* sm);
|
||||
|
||||
SubscribeMap* operator->();
|
||||
SubscribeMap* operator->() const;
|
||||
const SubscribeMap& operator*() const;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue