writeLock<T> method

Future<T> writeLock<T>(
  1. Future<T> callback(
    1. SqliteWriteContext tx
    ), {
  2. Duration? lockTimeout,
  3. String? debugContext,
})

Takes a global lock, without starting a transaction.

In most cases, writeTransaction should be used instead.

The lock applies to all SqliteConnection instances for a SqliteDatabase. Locks for separate SqliteDatabase instances on the same database file may be held concurrently.

If a timeout is set and no read connection becomes available in time, an AbortException will be thrown.

Implementation

Future<T> writeLock<T>(Future<T> Function(SqliteWriteContext tx) callback,
    {Duration? lockTimeout, String? debugContext}) {
  return abortableWriteLock(callback,
      debugContext: debugContext, abortTrigger: lockTimeout?.asTimeout);
}