diff --git a/api/current.xml b/api/current.xml index e75f2b28f13bf..96e1d2d933828 100644 --- a/api/current.xml +++ b/api/current.xml @@ -47785,6 +47785,19 @@ visibility="public" > + + + + 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. + * @return true if the transaction was yielded + */ + public boolean yieldIfContendedSafely(long sleepAfterYieldDelay) { + return yieldIfContendedHelper(true /* check yielding */, sleepAfterYieldDelay); + } + + private boolean yieldIfContendedHelper(boolean checkFullyYielded, long sleepAfterYieldDelay) { if (mLock.getQueueLength() == 0) { // Reset the lock acquire time since we know that the thread was willing to yield // the lock at this time. @@ -550,6 +566,13 @@ public class SQLiteDatabase extends SQLiteClosable { "Db locked more than once. yielfIfContended cannot yield"); } } + if (sleepAfterYieldDelay > 0) { + try { + Thread.sleep(sleepAfterYieldDelay); + } catch (InterruptedException e) { + Thread.interrupted(); + } + } beginTransaction(); return true; }