synchronized<T> method
Implementation
Future<T> synchronized<T>(
Future<T> Function() func,
) async {
final prev = last;
final completer = Completer<void>.sync();
last = completer.future;
try {
if (prev != null) {
await prev;
}
final result = func();
return result;
} finally {
if (identical(last, completer.future)) {
last = null;
}
completer.complete();
}
}