Rewrite raw memcard threading code. Intended to fix issue 7484.

You don't need to lock as it's std::atomic. I think busy loop is the proper answer here, it is waiting to serialize the next iteration of FlushThread.