Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cyber/transport/shm/condition_notifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool ConditionNotifier::Notify(const ReadableInfo& info) {
uint64_t seq = indicator_->next_seq.fetch_add(1);
uint64_t idx = seq % kBufLength;
indicator_->infos[idx] = info;
indicator_->seqs[idx] = seq;
indicator_->seqs[idx].store(seq, std::memory_order_release);

return true;
}
Expand All @@ -84,7 +84,7 @@ bool ConditionNotifier::Listen(int timeout_ms, ReadableInfo* info) {
uint64_t seq = indicator_->next_seq.load();
if (seq != next_seq_) {
auto idx = next_seq_ % kBufLength;
auto actual_seq = indicator_->seqs[idx];
auto actual_seq = indicator_->seqs[idx].load(std::memory_order_acquire);
if (actual_seq >= next_seq_) {
next_seq_ = actual_seq;
*info = indicator_->infos[idx];
Expand Down
2 changes: 1 addition & 1 deletion cyber/transport/shm/condition_notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ConditionNotifier : public NotifierBase {
struct Indicator {
std::atomic<uint64_t> next_seq = {0};
ReadableInfo infos[kBufLength];
uint64_t seqs[kBufLength] = {0};
std::atomic<uint64_t> seqs[kBufLength] = {0};
};

public:
Expand Down