3 ms·
https://whatdoesthiscodedo.com/g/5b205f1 https://whatdoesthiscodedo.com/g/5b205f1 > The function adds the specified item to the end of the linked list, while e
by eqvinox 4y ago
https://whatdoesthiscodedo.com/g/5b205f1 https://whatdoesthiscodedo.com/g/5b205f1
> The function adds the specified item to the end of the linked list, while ensuring thread safety using atomic operations. The function first increments the count of items in the list, then uses an atomic exchange operation to add the new item to the end of the list.
I'm positively surprised it was able to figure this out, especially after I intentionally removed the comments and changed the function name.
That said, this also shows its limits as it completely ignores the atomic memory barriers. Those are the really tricky part that you'd need an explainer for…
[source, in case anyone wonders: https://github.com/FRRouting/frr/blob/master/lib/atomlist.c https://github.com/FRRouting/frr/blob/master/lib/atomlist.c]