Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ff270fd authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 23474 into eclair

* changes:
  Breaking sleep after yield into small quanta.
parents d31825c6 600bdd82
Loading
Loading
Loading
Loading
+68 −55
Original line number Original line Diff line number Diff line
@@ -189,6 +189,8 @@ public class SQLiteDatabase extends SQLiteClosable {
    private static final int LOCK_ACQUIRED_WARNING_THREAD_TIME_IN_MS = 100;
    private static final int LOCK_ACQUIRED_WARNING_THREAD_TIME_IN_MS = 100;
    private static final int LOCK_ACQUIRED_WARNING_TIME_IN_MS_ALWAYS_PRINT = 2000;
    private static final int LOCK_ACQUIRED_WARNING_TIME_IN_MS_ALWAYS_PRINT = 2000;


    private static final int SLEEP_AFTER_YIELD_QUANTUM = 500;

    private long mLastLockMessageTime = 0L;
    private long mLastLockMessageTime = 0L;


    /** Used by native code, do not rename */
    /** Used by native code, do not rename */
@@ -567,11 +569,22 @@ public class SQLiteDatabase extends SQLiteClosable {
            }
            }
        }
        }
        if (sleepAfterYieldDelay > 0) {
        if (sleepAfterYieldDelay > 0) {
            // Sleep for up to sleepAfterYieldDelay milliseconds, waking up periodically to
            // check if anyone is using the database.  If the database is not contended,
            // retake the lock and return.
            long remainingDelay = sleepAfterYieldDelay;
            while (remainingDelay > 0) {
                try {
                try {
                Thread.sleep(sleepAfterYieldDelay);
                    Thread.sleep(remainingDelay < SLEEP_AFTER_YIELD_QUANTUM ?
                            remainingDelay : SLEEP_AFTER_YIELD_QUANTUM);
                } catch (InterruptedException e) {
                } catch (InterruptedException e) {
                    Thread.interrupted();
                    Thread.interrupted();
                }
                }
                remainingDelay -= SLEEP_AFTER_YIELD_QUANTUM;
                if (mLock.getQueueLength() == 0) {
                    break;
                }
            }
        }
        }
        beginTransaction();
        beginTransaction();
        return true;
        return true;