refactor: Null safe multilock
This commit is contained in:
parent
0cd73e846d
commit
4b9a2945f4
|
|
@ -1,4 +1,3 @@
|
||||||
// @dart=2.9
|
|
||||||
/*
|
/*
|
||||||
* Famedly Matrix SDK
|
* Famedly Matrix SDK
|
||||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||||
|
|
@ -40,7 +39,7 @@ class MultiLock<T> {
|
||||||
if (_completers[key] != null) {
|
if (_completers[key] != null) {
|
||||||
futures.add(() async {
|
futures.add(() async {
|
||||||
while (_completers[key] != null) {
|
while (_completers[key] != null) {
|
||||||
await _completers[key].future;
|
await _completers[key]!.future;
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +59,7 @@ class MultiLock<T> {
|
||||||
// we just have to simply unlock all the completers
|
// we just have to simply unlock all the completers
|
||||||
for (final key in uniqueKeys) {
|
for (final key in uniqueKeys) {
|
||||||
if (_completers[key] != null) {
|
if (_completers[key] != null) {
|
||||||
final completer = _completers[key];
|
final completer = _completers[key]!;
|
||||||
_completers.remove(key);
|
_completers.remove(key);
|
||||||
completer.complete();
|
completer.complete();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue