On Sonntag, 22. Juli 2018 17:01:29 CEST Umesh Kalappa wrote: > Allan , > > >>he might as well go traditional > > you mean using the locks ? >
No I am meant relying on undefined behavior. In your case I would recommend using modern atomics, which is defined behavior, and modern and fast. I was just reminded of all the nasty and theoretically wrong ways we used to do stuff like that 20 years ago to implement fallback locks. For instance using - O0, asm-declarations, relying on non-inlined functions calls as memory- barriers, etc. All stuff that "worked", but relied on various degrees of undefined behavior. Still if you are curious, it might be fun playing with stuff like that, and try to figure for yourself why it works, just remember it is undefined behavior and therefore not recommended. 'Allan