throttle<TResult> method
Function job
is executed only if the semaphore is not locked.
Implementation
Future<TResult?> throttle<TResult>(FutureOr<TResult> Function() job) async {
if (isLocked) {
return null;
}
try {
await lock();
return await job();
} finally {
release();
}
}