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

Side by Side 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, 6 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Pass interruption information along. 132 // Pass interruption information along.
133 if (wasInterrupted) { 133 if (wasInterrupted) {
134 Thread.currentThread().interrupt(); 134 Thread.currentThread().interrupt();
135 } 135 }
136 return result; 136 return result;
137 } 137 }
138 138
139 /** 139 /**
140 * Post |callable| to |handler| and wait for the result. 140 * Post |callable| to |handler| and wait for the result.
141 */ 141 */
142 public static <V> V invokeUninterruptibly(final Handler handler, final Callabl e<V> callable) { 142 public static <V> V invokeAtFrontUninterruptibly(
143 final Handler handler, final Callable<V> callable) {
144 if (handler.getLooper().getThread() == Thread.currentThread()) {
145 V value;
146 try {
147 value = callable.call();
148 } catch (Exception e) {
149 final RuntimeException runtimeException =
150 new RuntimeException("Callable threw exception: " + e);
151 runtimeException.setStackTrace(e.getStackTrace());
152 throw runtimeException;
153 }
154 return value;
155 }
143 class Result { 156 class Result {
144 public V value; 157 public V value;
145 } 158 }
146 final Result result = new Result(); 159 final Result result = new Result();
147 final CountDownLatch barrier = new CountDownLatch(1); 160 final CountDownLatch barrier = new CountDownLatch(1);
148 handler.post(new Runnable() { 161 handler.post(new Runnable() {
149 @Override public void run() { 162 @Override public void run() {
150 try { 163 try {
151 result.value = callable.call(); 164 result.value = callable.call();
152 } catch (Exception e) { 165 } catch (Exception e) {
153 final RuntimeException runtimeException = 166 final RuntimeException runtimeException =
154 new RuntimeException("Callable threw exception: " + e); 167 new RuntimeException("Callable threw exception: " + e);
155 runtimeException.setStackTrace(e.getStackTrace()); 168 runtimeException.setStackTrace(e.getStackTrace());
156 throw runtimeException; 169 throw runtimeException;
157 } 170 }
158 barrier.countDown(); 171 barrier.countDown();
159 } 172 }
160 }); 173 });
161 awaitUninterruptibly(barrier); 174 awaitUninterruptibly(barrier);
162 return result.value; 175 return result.value;
163 } 176 }
164 177
165 /** 178 /**
166 * Post |runner| to |handler| and wait for the result. 179 * Post |runner| to |handler|, at the front, and wait for
180 * completion.
167 */ 181 */
168 public static void invokeUninterruptibly(final Handler handler, final Runnable runner) { 182 public static void invokeAtFrontUninterruptibly(final Handler handler, final R unnable runner) {
183 if (handler.getLooper().getThread() == Thread.currentThread()) {
184 runner.run();
185 return;
186 }
169 final CountDownLatch barrier = new CountDownLatch(1); 187 final CountDownLatch barrier = new CountDownLatch(1);
170 handler.post(new Runnable() { 188 handler.postAtFrontOfQueue(new Runnable() {
171 @Override public void run() { 189 @Override
172 runner.run(); 190 public void run() {
191 runner.run();
173 barrier.countDown(); 192 barrier.countDown();
174 } 193 }
175 }); 194 });
176 awaitUninterruptibly(barrier); 195 awaitUninterruptibly(barrier);
177 } 196 }
178 } 197 }
OLDNEW
« 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