pull out posix mutex code into AllocatorMutex so that it can be made cross platform.

std::mutex is sadly not an option because it allocates memory :(