| 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 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 timeRemainingMs = timeoutMs - elapsedTimeMs; | 129 timeRemainingMs = timeoutMs - elapsedTimeMs; |
| 130 } | 130 } |
| 131 } while (timeRemainingMs > 0); | 131 } while (timeRemainingMs > 0); |
| 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 public static void waitUninterruptibly(final Object object) { |
| 140 executeUninterruptibly(new BlockingOperation() { |
| 141 @Override |
| 142 public void run() throws InterruptedException { |
| 143 object.wait(); |
| 144 } |
| 145 }); |
| 146 } |
| 147 |
| 139 /** | 148 /** |
| 140 * Post |callable| to |handler| and wait for the result. | 149 * Post |callable| to |handler| and wait for the result. |
| 141 */ | 150 */ |
| 142 public static <V> V invokeAtFrontUninterruptibly( | 151 public static <V> V invokeAtFrontUninterruptibly( |
| 143 final Handler handler, final Callable<V> callable) { | 152 final Handler handler, final Callable<V> callable) { |
| 144 if (handler.getLooper().getThread() == Thread.currentThread()) { | 153 if (handler.getLooper().getThread() == Thread.currentThread()) { |
| 145 V value; | 154 V value; |
| 146 try { | 155 try { |
| 147 value = callable.call(); | 156 value = callable.call(); |
| 148 } catch (Exception e) { | 157 } catch (Exception e) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 handler.postAtFrontOfQueue(new Runnable() { | 197 handler.postAtFrontOfQueue(new Runnable() { |
| 189 @Override | 198 @Override |
| 190 public void run() { | 199 public void run() { |
| 191 runner.run(); | 200 runner.run(); |
| 192 barrier.countDown(); | 201 barrier.countDown(); |
| 193 } | 202 } |
| 194 }); | 203 }); |
| 195 awaitUninterruptibly(barrier); | 204 awaitUninterruptibly(barrier); |
| 196 } | 205 } |
| 197 } | 206 } |
| OLD | NEW |