run<T> method
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();
}
}