mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 09:16:19 +01:00
10 lines
302 B
Dart
10 lines
302 B
Dart
|
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>{};
|
||
|
}
|