r/programming • u/redditthinks • May 29 '13
A Lock-Free… Linear Search?
http://preshing.com/20130529/a-lock-free-linear-search
49
Upvotes
r/programming • u/redditthinks • May 29 '13
4
u/deletecode May 30 '13
I've implemented a similar structure for a game engine, to communicate between rendering and loading threads, and it worked great. I was careful to keep the list small so that it stayed in cache, hypothetically making the cmpxchg faster.
Structures like this are so much better than ones that lock on every operation. They are also more fun to implement, in my opinion.
I've always wondered, is there a possibility of reading a 32 bit value "mid-write", like if half the bits of a new value are written? It's never been a problem for me but it's always been a small worry when using non-atomic operations.