Lock free & RAII?


#1

Hi,

I am currently trying to pass objects from my GUI thread to my audio thread.

I want my audio thread to be lock free. And if possible also some form of RAII.
Normally you could use shared_ptr for RAII. But an atomic shared_ptr is not lock free, as fas as I know (I debugged shared_ptr in VS 2015 and it acquires a spinning lock for atomic_load. So unfortunately that does not seem to be lock free. )
So maybe I am stuck with atomic raw pointers? They are lock free. But I would need to implement my own memory management. I would like to avoid that :slight_smile:

Therefore I was wondering: is there a good way to combine lock free with RAII?
How do you guys solve this?
Should I implement my own garbage collector?

Are there any good articles or books on this subject?


#2

watch the whole thing.