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