[DiscordArchive] "Atomic types are also allowed to be sometimes lock-free, e.g. if only aligned memory accesses are n
[DiscordArchive] "Atomic types are also allowed to be sometimes lock-free, e.g. if only aligned memory accesses are n
Archived author: jackpoz • Posted: 2024-04-02T11:36:14.459000+00:00
Original source
"Atomic types are also allowed to be sometimes lock-free, e.g. if only aligned memory accesses are naturally atomic on a given architecture" I guess this answer your question ?
Archived author: jackpoz • Posted: 2024-04-02T11:36:27.293000+00:00
Original source
the answer being "sometimes"
Archived author: Tea • Posted: 2024-04-02T11:36:41.005000+00:00
Original source
no, not at all
Archived author: Tea • Posted: 2024-04-02T11:37:24.653000+00:00
Original source
its about this line specifically https://github.com/TrinityCore/TrinityCo...ueue.h#L65 and whether this breaks the safety of entire Dequeue operation or not
Archived author: jackpoz • Posted: 2024-04-02T11:40:27.977000+00:00
Original source
well it's single consumer, so Dequeue is called only once at a time
Archived author: jackpoz • Posted: 2024-04-02T11:41:20.214000+00:00
Original source
so once you have next, that's going to always be valid and the whole object it points to
Archived author: Tea • Posted: 2024-04-02T11:41:54.410000+00:00
Original source
but it has to synchronize with producers
Archived author: jackpoz • Posted: 2024-04-02T11:44:46.027000+00:00
Original source
Node* tail = _tail.load(std::memory_order_relaxed);
Node* next = tail->Next.load(std::memory_order_acquire);
Lines 60 and 61 are the only ones that you sync with producers
Archived author: jackpoz • Posted: 2024-04-02T11:45:54.759000+00:00
Original source
when producer calls Enqueue(), it gives up any reference to ->Data
Archived author: jackpoz • Posted: 2024-04-02T11:47:30.518000+00:00
Original source
having a single consumer allows to take a lot of shortcuts and that implementation takes them all