yieldIfContendedSafely method

Future<bool> yieldIfContendedSafely ([int sleepAfterYieldDelay = 0 ])

Temporarily end the transaction to let other threads run.

The transaction is assumed to be successful so far. Do not call setTransactionSuccessful before calling this. When this returns a new transaction will have been created but not marked as successful. This assumes that there are no nested transactions (beginTransaction has only been called once) and will throw an exception if that is not the case.

If sleepAfterYieldDelay > 0, sleep this long before starting a new transaction if the lock was actually yielded. This will allow other background threads to make some more progress than they would if we started the transaction immediately.

See: https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#yieldIfContendedSafely()

Implementation

Future<bool> yieldIfContendedSafely(
    [final int sleepAfterYieldDelay = 0]) async {
  final Map<String, dynamic> request = <String, dynamic>{
    'id': id,
    'sleepAfterYieldDelay': sleepAfterYieldDelay
  };
  return await _channel.invokeMethod('yieldIfContendedSafely', request);
}