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.
This is needed for plugging into an existing Looper because
we won't call ::run() on the main thread (this is called
on the Java side of the application automatically by Android).
But we still need to wake up and process the events. For that
we create a pipe and write to the pipe to wake up the main
loop and we process events on the callback of the fd handler.
Fixes#4682