mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-15 12:42:14 -04:00
more messages work
This commit is contained in:
parent
634543910b
commit
ff14969ffa
12 changed files with 226 additions and 192 deletions
|
@ -4,8 +4,8 @@ import 'async_tag_lock.dart';
|
|||
|
||||
AsyncTagLock<Object> _keys = AsyncTagLock();
|
||||
|
||||
void singleFuture(Object tag, Future<void> Function() closure,
|
||||
{void Function()? onBusy}) {
|
||||
void singleFuture<T>(Object tag, Future<T> Function() closure,
|
||||
{void Function()? onBusy, void Function(T)? onDone}) {
|
||||
if (!_keys.tryLock(tag)) {
|
||||
if (onBusy != null) {
|
||||
onBusy();
|
||||
|
@ -13,7 +13,13 @@ void singleFuture(Object tag, Future<void> Function() closure,
|
|||
return;
|
||||
}
|
||||
unawaited(() async {
|
||||
await closure();
|
||||
_keys.unlockTag(tag);
|
||||
try {
|
||||
final out = await closure();
|
||||
if (onDone != null) {
|
||||
onDone(out);
|
||||
}
|
||||
} finally {
|
||||
_keys.unlockTag(tag);
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue