| OLD | NEW |
| 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 |
| 11 package org.webrtc; | 11 package org.webrtc; |
| 12 | 12 |
| 13 import android.os.Handler; | 13 import android.os.Handler; |
| 14 import android.os.Looper; | 14 import android.os.Looper; |
| 15 import android.os.SystemClock; | 15 import android.os.SystemClock; |
| 16 | |
| 17 import java.util.concurrent.Callable; | 16 import java.util.concurrent.Callable; |
| 18 import java.util.concurrent.CountDownLatch; | 17 import java.util.concurrent.CountDownLatch; |
| 19 import java.util.concurrent.TimeUnit; | 18 import java.util.concurrent.TimeUnit; |
| 20 | 19 |
| 21 public class ThreadUtils { | 20 public class ThreadUtils { |
| 22 /** | 21 /** |
| 23 * Utility class to be used for checking that a method is called on the correc
t thread. | 22 * Utility class to be used for checking that a method is called on the correc
t thread. |
| 24 */ | 23 */ |
| 25 public static class ThreadChecker { | 24 public static class ThreadChecker { |
| 26 private Thread thread = Thread.currentThread(); | 25 private Thread thread = Thread.currentThread(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 public static void invokeAtFrontUninterruptibly(final Handler handler, final R
unnable runner) { | 203 public static void invokeAtFrontUninterruptibly(final Handler handler, final R
unnable runner) { |
| 205 invokeAtFrontUninterruptibly(handler, new Callable<Void>() { | 204 invokeAtFrontUninterruptibly(handler, new Callable<Void>() { |
| 206 @Override | 205 @Override |
| 207 public Void call() { | 206 public Void call() { |
| 208 runner.run(); | 207 runner.run(); |
| 209 return null; | 208 return null; |
| 210 } | 209 } |
| 211 }); | 210 }); |
| 212 } | 211 } |
| 213 | 212 |
| 214 private static StackTraceElement[] concatStackTraces( | 213 static StackTraceElement[] concatStackTraces( |
| 215 StackTraceElement[] inner, StackTraceElement[] outer) { | 214 StackTraceElement[] inner, StackTraceElement[] outer) { |
| 216 final StackTraceElement[] combined = new StackTraceElement[inner.length + ou
ter.length]; | 215 final StackTraceElement[] combined = new StackTraceElement[inner.length + ou
ter.length]; |
| 217 System.arraycopy(inner, 0, combined, 0, inner.length); | 216 System.arraycopy(inner, 0, combined, 0, inner.length); |
| 218 System.arraycopy(outer, 0, combined, inner.length, outer.length); | 217 System.arraycopy(outer, 0, combined, inner.length, outer.length); |
| 219 return combined; | 218 return combined; |
| 220 } | 219 } |
| 221 } | 220 } |
| OLD | NEW |