withPermit<T> method

Future<T> withPermit<T>(
  1. Future<T> action()
)

Implementation

Future<T> withPermit<T>(Future<T> Function() action) async {
  await acquire();
  try {
    final stopwatch = Stopwatch()..start();
    final t = await action();
    onEachCompleted(stopwatch.elapsed.inMilliseconds);
    stopwatch.stop();
    return t;
  } finally {
    release();
  }
}