Implement own recursive_mutex, generalize lock_guard