runLocked<TResult> method
Function job
is executed immediately if the semaphore is not locked,
as soon as the last scheduled job finishes otherwise.
Implementation
Future<TResult> runLocked<TResult>(FutureOr<TResult> Function() job) async {
try {
await lock();
return await job();
} finally {
release();
}
}