better linting

This commit is contained in:
Mguy13 2023-01-01 13:04:22 +01:00
parent c7324a6b19
commit aa31a79d20
26 changed files with 163 additions and 131 deletions

View file

@ -4,19 +4,19 @@ import 'dart:ui';
/// A simple Mutex implementation using a [Completer].
class Mutex {
final _completerQueue = Queue<Completer>();
final _completerQueue = Queue<Completer<void>>();
/// Runs the given [run] function-block in a thread-safe/blocked zone. A convenient `unlock()`
/// is provided, which can be called anywhere to signal re-entry.
FutureOr<T> lockAndRun<T>({
required FutureOr<T> Function(VoidCallback unlock) run,
}) async {
final completer = Completer();
final completer = Completer<void>();
_completerQueue.add(completer);
if (_completerQueue.first != completer) {
await _completerQueue.removeFirst().future;
}
final value = await run(() => completer.complete());
final value = await run(completer.complete);
return value;
}