summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-02-17 18:54:18 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-02-23 10:10:23 +0100
commitdc14b540e9b90d046e108132ad93a631e88f550a (patch)
treeeae4b591afbabefc1bcc8b542df00e1b0e4562be /android
parent484d904d4dfaad9397c9599292c3abf30880d5bf (diff)
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
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index b76a68455746..d5b07815ef00 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -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: