object: fix race detected by tsan in mpsc queue

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-11-30 12:00:45 -07:00
parent 40dcef1836
commit 4bcafe89c4

View file

@ -350,6 +350,15 @@ pub fn Queue(comptime Value: type) type {
// Lost race (with another takeAll() or pop()), retry from start
continue :outer;
}
// Ensure all previous atomic operations (including linking) are complete
// Specifically this part of pushRaw():
//
// // Link previous node to new node
// @atomicStore(?*Node, &prev.next, node, .release);
//
_ = @atomicLoad(*Node, &q.head, .acquire);
return tail;
}
}