Kaydet (Commit) dc14b540 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Miklos Vajna

android: change back to LinkedBlockingQueue

PriorityBlockingQueue doesn't preserve order within equal elements.
This means elements with same priority will be returned in
arbitrary order, which we don't want to have - for example we want
tiles to render in the same order they were added to the queue.
Also there is no measurable or felt benefit that priority bring so
lets just drop PriorityBlockingQueue for LinkedBlockingQueue.

Change-Id: I6ffe0bf896f0e18e8b5ffc75a4001d8f40515a56
üst 484d904d
......@@ -15,12 +15,13 @@ import org.mozilla.gecko.gfx.SubTile;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
public class LOKitThread extends Thread implements TileProvider.TileInvalidationCallback {
private static final String LOGTAG = LOKitThread.class.getSimpleName();
private PriorityBlockingQueue<LOEvent> mEventQueue = new PriorityBlockingQueue<LOEvent>();
private LinkedBlockingQueue<LOEvent> mEventQueue = new LinkedBlockingQueue<LOEvent>();
private LibreOfficeMainActivity mApplication;
private TileProvider mTileProvider;
private ImmutableViewportMetrics mViewportMetrics;
......@@ -30,9 +31,23 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
TileProviderFactory.initialize();
}
@Override
public void run() {
while (true) {
LOEvent event;
try {
event = mEventQueue.take();
processEvent(event);
} catch (InterruptedException exception) {
throw new RuntimeException(exception);
}
}
}
private void tileRequest(ComposedTileLayer composedTileLayer, TileIdentifier tileId) {
if (mTileProvider == null)
if (mTileProvider == null) {
return;
}
if (composedTileLayer.isStillValid(tileId)) {
CairoImage image = mTileProvider.createTile(tileId.x, tileId.y, tileId.size, tileId.zoom);
......@@ -143,16 +158,6 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
}
}
@Override
public void run() {
try {
while (true) {
processEvent(mEventQueue.take());
}
} catch (InterruptedException ex) {
}
}
private void processEvent(LOEvent event) {
switch (event.mType) {
case LOEvent.LOAD:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment