Future<void> lock(Lock lock, Future Function() func) async { try { await lock.acquire(); await func(); } finally { lock.release(); } }