1
0
Fork 0
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:
Vladislav 2024-03-09 11:49:18 +03:00 committed by GitHub
parent 292c5bcd71
commit 6df0fa4948
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -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();
}

View file

@ -81,7 +81,7 @@ class ChannelStore {
SubscribeMap* Get() const;
void Set(SubscribeMap* sm);
SubscribeMap* operator->();
SubscribeMap* operator->() const;
const SubscribeMap& operator*() const;
private: