Fix false queue-full detection in audio diagnostics
This commit is contained in:
1 parent
233056a83a
commit
7d75afd4c5
1 file changed
+2
-1
@@ -59,6 +59,7 @@ void publish(const void* device, int kind, int stage, int64_t value, int64_t det
|
||||
for (int attempt = 0; attempt < 4; ++attempt) {
|
||||
auto& slot = queue[pos % kCapacity];
|
||||
const auto seq = slot.sequence.load(std::memory_order_acquire);
|
||||
if (seq < pos) break; // Полное кольцо; сравниваем с позицией именно этого slot.
|
||||
if (seq == pos && writePosition.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed)) {
|
||||
auto& e = slot.event;
|
||||
e.device = reinterpret_cast<uintptr_t>(device); e.wall = wall; e.cpu = cpu;
|
||||
@@ -74,7 +75,7 @@ void publish(const void* device, int kind, int stage, int64_t value, int64_t det
|
||||
slot.sequence.store(pos + 1, std::memory_order_release);
|
||||
return;
|
||||
}
|
||||
if (seq < pos) break; // Полное кольцо.
|
||||
// Неудачный CAS меняет pos: старый seq уже нельзя сравнивать с новой позицией.
|
||||
pos = writePosition.load(std::memory_order_relaxed);
|
||||
}
|
||||
lost.fetch_add(1, std::memory_order_relaxed);
|
||||
|
||||
Reference in new issue
Block a user