run<T> method

Future<T> run<T>(
  1. Future<T> func()
)
inherited

Acquire the semaphore, asynchronously run func and release the semaphore afterwards.

The returned value is the result of func

Implementation

Future<T> run<T>(Future<T> Function() func) async {
  await acquire();
  try {
    var result = await func();
    return result;
  } finally {
    release();
  }
}