am 6ff270fd: Merge change 23474 into eclair
Merge commit '6ff270fd854d7c62f857998446fccb803004f1c3' into eclair-plus-aosp * commit '6ff270fd854d7c62f857998446fccb803004f1c3': Breaking sleep after yield into small quanta.
This commit is contained in:
@@ -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,10 +569,21 @@ public class SQLiteDatabase extends SQLiteClosable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sleepAfterYieldDelay > 0) {
|
if (sleepAfterYieldDelay > 0) {
|
||||||
try {
|
// Sleep for up to sleepAfterYieldDelay milliseconds, waking up periodically to
|
||||||
Thread.sleep(sleepAfterYieldDelay);
|
// check if anyone is using the database. If the database is not contended,
|
||||||
} catch (InterruptedException e) {
|
// retake the lock and return.
|
||||||
Thread.interrupted();
|
long remainingDelay = sleepAfterYieldDelay;
|
||||||
|
while (remainingDelay > 0) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(remainingDelay < SLEEP_AFTER_YIELD_QUANTUM ?
|
||||||
|
remainingDelay : SLEEP_AFTER_YIELD_QUANTUM);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.interrupted();
|
||||||
|
}
|
||||||
|
remainingDelay -= SLEEP_AFTER_YIELD_QUANTUM;
|
||||||
|
if (mLock.getQueueLength() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
beginTransaction();
|
beginTransaction();
|
||||||
|
|||||||
Reference in New Issue
Block a user