acquireAll method

Future<List<LockGrant>> acquireAll(
  1. List<String> tables,
  2. LockMode mode, {
  3. int timeoutMs = 5000,
})

Implementation

Future<List<LockGrant>> acquireAll(
  List<String> tables,
  LockMode mode, {
  int timeoutMs = 5000,
}) async {
  final sorted = [...tables]..sort();
  final grants = <LockGrant>[];
  for (final t in sorted) {
    try {
      final g = mode == LockMode.read
          ? await acquireRead(t, timeoutMs: timeoutMs)
          : await acquireWrite(t, timeoutMs: timeoutMs);
      grants.add(g);
    } catch (e) {
      // Release any locks already granted on error
      for (final g in grants) release(g);
      rethrow;
    }
  }
  return grants;
}