Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: webrtc/base/java/src/org/webrtc/ThreadUtils.java

Issue 1988043002: Call java SurfaceTextureHelper.dispose from the corresponding C++ destructor. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Indentation tweak. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/java/src/org/webrtc/ThreadUtils.java
diff --git a/webrtc/base/java/src/org/webrtc/ThreadUtils.java b/webrtc/base/java/src/org/webrtc/ThreadUtils.java
index 8eeebc84dc2c0dd57eecc2c02c2ff3c8fc1252cd..95d41ba56337d646877781bfc19edb3b6f96e298 100644
--- a/webrtc/base/java/src/org/webrtc/ThreadUtils.java
+++ b/webrtc/base/java/src/org/webrtc/ThreadUtils.java
@@ -139,7 +139,20 @@ public class ThreadUtils {
/**
* Post |callable| to |handler| and wait for the result.
*/
- public static <V> V invokeUninterruptibly(final Handler handler, final Callable<V> callable) {
+ public static <V> V invokeAtFrontUninterruptibly(
+ final Handler handler, final Callable<V> callable) {
+ if (handler.getLooper().getThread() == Thread.currentThread()) {
+ V value;
+ try {
+ value = callable.call();
+ } catch (Exception e) {
+ final RuntimeException runtimeException =
+ new RuntimeException("Callable threw exception: " + e);
+ runtimeException.setStackTrace(e.getStackTrace());
+ throw runtimeException;
+ }
+ return value;
+ }
class Result {
public V value;
}
@@ -163,13 +176,19 @@ public class ThreadUtils {
}
/**
- * Post |runner| to |handler| and wait for the result.
+ * Post |runner| to |handler|, at the front, and wait for
+ * completion.
*/
- public static void invokeUninterruptibly(final Handler handler, final Runnable runner) {
+ public static void invokeAtFrontUninterruptibly(final Handler handler, final Runnable runner) {
+ if (handler.getLooper().getThread() == Thread.currentThread()) {
+ runner.run();
+ return;
+ }
final CountDownLatch barrier = new CountDownLatch(1);
- handler.post(new Runnable() {
- @Override public void run() {
- runner.run();
+ handler.postAtFrontOfQueue(new Runnable() {
+ @Override
+ public void run() {
+ runner.run();
barrier.countDown();
}
});
« no previous file with comments | « webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698