Merge \"Reduce contention of ApplicationsState locks\" into nyc-mr1-dev

am: 9e133205e3

Change-Id: I3ac7fca652b60ebc66e8804e31c8cfd034b8b037
This commit is contained in:
Jason Monk
2016-07-15 19:55:45 +00:00
committed by android-build-merger

View File

@@ -582,10 +582,10 @@ public class ApplicationsState {
public ArrayList<AppEntry> rebuild(AppFilter filter, Comparator<AppEntry> comparator, public ArrayList<AppEntry> rebuild(AppFilter filter, Comparator<AppEntry> comparator,
boolean foreground) { boolean foreground) {
synchronized (mRebuildSync) { synchronized (mRebuildSync) {
synchronized (mEntriesMap) { synchronized (mRebuildingSessions) {
mRebuildingSessions.add(this); mRebuildingSessions.add(this);
mRebuildRequested = true; mRebuildRequested = true;
mRebuildAsync = false; mRebuildAsync = true;
mRebuildFilter = filter; mRebuildFilter = filter;
mRebuildComparator = comparator; mRebuildComparator = comparator;
mRebuildForeground = foreground; mRebuildForeground = foreground;
@@ -597,23 +597,7 @@ public class ApplicationsState {
} }
} }
// We will wait for .25s for the list to be built. return null;
long waitend = SystemClock.uptimeMillis()+250;
while (mRebuildResult == null) {
long now = SystemClock.uptimeMillis();
if (now >= waitend) {
break;
}
try {
mRebuildSync.wait(waitend - now);
} catch (InterruptedException e) {
}
}
mRebuildAsync = true;
return mRebuildResult;
} }
} }
@@ -776,7 +760,7 @@ public class ApplicationsState {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
// Always try rebuilding list first thing, if needed. // Always try rebuilding list first thing, if needed.
ArrayList<Session> rebuildingSessions = null; ArrayList<Session> rebuildingSessions = null;
synchronized (mEntriesMap) { synchronized (mRebuildingSessions) {
if (mRebuildingSessions.size() > 0) { if (mRebuildingSessions.size() > 0) {
rebuildingSessions = new ArrayList<Session>(mRebuildingSessions); rebuildingSessions = new ArrayList<Session>(mRebuildingSessions);
mRebuildingSessions.clear(); mRebuildingSessions.clear();