std::atomic<bool> is implemented lock free which doesn't work
on ARMv5 and seems like the compiler is generating bogus code.
This workaround is a naive implementation using regular mutexes.
They are not supported by ARMv5 and the compiler is generating
bogus code. std::atomic might be implemented lock-free for some
types, but we are going to introduce a naive polyfill to make
sure that doesn't happen on ARMv5 (only).