7 ms·
Dmitry Vyukov keeps a great resource for learning about lock-free algorithms (and other interesting things) here: http://www.1024cores.net/home/lock-free-algori
by edsrzf 13y ago
Dmitry Vyukov keeps a great resource for learning about lock-free algorithms (and other interesting things) here: http://www.1024cores.net/home/lock-free-algorithms/introduction http://www.1024cores.net/home/lock-free-algorithms/introduct...
- dannywoodz 13y agoIsn't the very first example in that article flawed? void decrement_reference_counter(rc_base* obj) { if (0 == atomic_decrement(obj->rc)) delete obj; } This is classic test-then-act, isn't it? What happens if another thread bumps obj->rc after the comparison to 0, but before the deletion? That other thread could find itself referring to a suddenly-deleted object, or am I missing something?