I am looking for a collection data structure that is:
- thread safe
- lock free
- non-allocating (amortized or pre-allocated is fine)
- non-intrusive
- not using exotic intrinsics
Element order does not matter. Stack, queue, bag, anything is fine. I have found plenty of examples that fulfill four of these five requirements, for example:
- .NET's List is not thread safe.
- If I put a mutex on it, then it's not lock free.
- .NET's ConcurrentStack is thread safe, lock free, uses a simple
CompareExchange, but allocates a newNodefor each element. - If I move the
nextpointer from theNodeto the element itself, then it's intrusive. - Array based lock free data structures tend to require multi-word intrinsics.
I feel like I'm missing something super obvious. This should be a solved problem.