Add TaggedScheduler, couple lifetime of tasks and orchestrator (#2398)
This commit is contained in:
@@ -120,11 +120,6 @@ public abstract class MapRenderer implements MapRendererScheduler {
|
||||
this.queueEvent((Runnable) runnable);
|
||||
}
|
||||
|
||||
/// Wait indefinitely for the queue to become empty
|
||||
public void waitForEmpty() {
|
||||
waitForEmpty(0);
|
||||
}
|
||||
|
||||
private native void nativeInitialize(MapRenderer self,
|
||||
float pixelRatio,
|
||||
String localIdeographFontFamily);
|
||||
|
||||
@@ -16,7 +16,4 @@ public interface MapRendererScheduler {
|
||||
|
||||
@Keep
|
||||
void waitForEmpty();
|
||||
|
||||
@Keep
|
||||
long waitForEmpty(long timeoutMillis);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceVi
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public long waitForEmpty(long timeoutMillis) {
|
||||
return glSurfaceView.waitForEmpty(timeoutMillis);
|
||||
public void waitForEmpty() {
|
||||
glSurfaceView.waitForEmpty();
|
||||
}
|
||||
}
|
||||
@@ -322,8 +322,8 @@ public class MapLibreGLSurfaceView extends SurfaceView implements SurfaceHolder.
|
||||
* @param timeoutMillis Timeout in milliseconds
|
||||
* @return Number of queue items remaining
|
||||
*/
|
||||
public long waitForEmpty(long timeoutMillis) {
|
||||
return glThread.waitForEmpty(timeoutMillis);
|
||||
public void waitForEmpty() {
|
||||
glThread.waitForEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -1038,31 +1038,16 @@ public class MapLibreGLSurfaceView extends SurfaceView implements SurfaceHolder.
|
||||
* @param timeoutMillis Timeout in milliseconds, zero for indefinite wait
|
||||
* @return Number of queue items remaining
|
||||
*/
|
||||
public int waitForEmpty(long timeoutMillis) {
|
||||
final long startTime = System.nanoTime();
|
||||
public void waitForEmpty() {
|
||||
synchronized (glThreadManager) {
|
||||
// Wait for the queue to be empty
|
||||
while (!this.eventQueue.isEmpty()) {
|
||||
if (timeoutMillis > 0) {
|
||||
final long elapsedMillis = (System.nanoTime() - startTime) / 1000 / 1000;
|
||||
if (elapsedMillis < timeoutMillis) {
|
||||
try {
|
||||
glThreadManager.wait(timeoutMillis - elapsedMillis);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
glThreadManager.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
try {
|
||||
glThreadManager.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
return this.eventQueue.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ public class TextureViewMapRenderer extends MapRenderer {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public long waitForEmpty(long timeoutMillis) {
|
||||
return renderThread.waitForEmpty(timeoutMillis);
|
||||
public void waitForEmpty() {
|
||||
renderThread.waitForEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -141,31 +141,16 @@ class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextu
|
||||
* @return The number of items remaining in the queue
|
||||
*/
|
||||
@UiThread
|
||||
int waitForEmpty(long timeoutMillis) {
|
||||
final long startTime = System.nanoTime();
|
||||
void waitForEmpty() {
|
||||
synchronized (lock) {
|
||||
// Wait for the queue to be empty
|
||||
while (!this.eventQueue.isEmpty()) {
|
||||
if (timeoutMillis > 0) {
|
||||
final long elapsedMillis = (System.nanoTime() - startTime) / 1000 / 1000;
|
||||
if (elapsedMillis < timeoutMillis) {
|
||||
try {
|
||||
lock.wait(timeoutMillis - elapsedMillis);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
lock.wait(0);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
try {
|
||||
lock.wait(0);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
return this.eventQueue.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user