diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-07-22 16:09:01 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-08-03 22:42:17 +0200 |
commit | 1d3ea0e7535cf1b1213767a549be02b9a624759d (patch) | |
tree | 881a48c18914c7b8d285d1516f0870c4fbe7460f /android/experimental | |
parent | e9c7159baf6f09b769e39b4d377d0f115edbf556 (diff) |
LOAndroid3: use LinkedBlockingQueue - block until there are event
Change-Id: Ia375c28d5adde5a6b2927e9b46105cfccd0b0f10
Diffstat (limited to 'android/experimental')
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java index 456f7b73199f..c418b4c40c7a 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java @@ -9,13 +9,13 @@ import org.mozilla.gecko.gfx.SubTile; import org.mozilla.gecko.gfx.ViewportMetrics; import java.util.ArrayList; -import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.LinkedBlockingQueue; public class LOKitThread extends Thread { private static final String LOGTAG = LOKitThread.class.getSimpleName(); private static final int TILE_SIZE = 256; - public ConcurrentLinkedQueue<LOEvent> mEvents = new ConcurrentLinkedQueue<LOEvent>(); + public LinkedBlockingQueue<LOEvent> mEventQueue = new LinkedBlockingQueue<LOEvent>(); private LibreOfficeMainActivity mApplication; private TileProvider mTileProvider; private ViewportMetrics mViewportMetrics; @@ -97,10 +97,7 @@ public class LOKitThread extends Thread { try { boolean drawn = false; while (true) { - if (!mEvents.isEmpty()) { - processEvent(mEvents.poll()); - } - Thread.sleep(100L); + processEvent(mEventQueue.take()); } } catch (InterruptedException ex) { } @@ -123,6 +120,6 @@ public class LOKitThread extends Thread { public void queueEvent(LOEvent event) { Log.i(LOGTAG, "Event: " + event.getTypeString()); - mEvents.add(event); + mEventQueue.add(event); } } |