requestLock<T> abstract method

Future<T> requestLock<T>(
  1. Future<T> body(
    1. LockToken lock
    ), {
  2. Future<void>? abortTrigger,
})

Runs body with an exclusive lock on the database.

This can be used to implement transactions on the database, where multiple statements may have to run without interference from other tabs.

The callback receives a LockToken, which can be passed to select and execute to run statements.

The abortTrigger can be used to abort requesting the lock. When that future completes before the lock has been granted, the future may complete with a AbortException without ever invoking body.

Implementation

Future<T> requestLock<T>(Future<T> Function(LockToken lock) body,
    {Future<void>? abortTrigger});