1
0
Fork 0
mirror of https://gitlab.com/nkming2/nc-photos.git synced 2025-03-12 18:28:52 +01:00
nc-photos/app/lib/web/lock.dart

10 lines
302 B
Dart
Raw Normal View History

2022-03-15 10:28:03 +01:00
import 'package:synchronized/synchronized.dart' as dart;
// Isolates are not supported on web
class Lock {
static Future<T> synchronized<T>(int lockId, Future<T> Function() fn) =>
(_locks[lockId] ??= dart.Lock(reentrant: true)).synchronized(fn);
static final _locks = <int, dart.Lock>{};
}