run<R> method

  1. @override
Future<R> run<R>(
  1. Future<R> action(
    1. SqlConnection
    )
)
override

Runs action exclusively; the next lease starts after its future settles.

Implementation

@override
Future<R> run<R>(Future<R> Function(SqlConnection) action) {
  if (_closed) {
    throw const OrmException('DRIVER.CLOSED', 'SQLite driver is closed.');
  }
  // Queue the whole lease: no caller can enter another caller's transaction.
  final result = _tail.then((_) => action(_connection));
  _tail = result.then<void>((_) {}, onError: (Object _, StackTrace _) {});
  return result;
}