| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 result.value = callable.call(); | 119 result.value = callable.call(); |
| 120 } catch (Exception e) { | 120 } catch (Exception e) { |
| 121 throw new RuntimeException("Callable threw exception: " + e); | 121 throw new RuntimeException("Callable threw exception: " + e); |
| 122 } | 122 } |
| 123 barrier.countDown(); | 123 barrier.countDown(); |
| 124 } | 124 } |
| 125 }); | 125 }); |
| 126 awaitUninterruptibly(barrier); | 126 awaitUninterruptibly(barrier); |
| 127 return result.value; | 127 return result.value; |
| 128 } | 128 } |
| 129 |
| 130 /** |
| 131 * Post |runner| to |handler| and wait for the result. |
| 132 */ |
| 133 public static void invokeUninterruptibly(final Handler handler, final Runnable
runner) { |
| 134 final CountDownLatch barrier = new CountDownLatch(1); |
| 135 handler.post(new Runnable() { |
| 136 @Override public void run() { |
| 137 runner.run(); |
| 138 barrier.countDown(); |
| 139 } |
| 140 }); |
| 141 awaitUninterruptibly(barrier); |
| 142 } |
| 129 } | 143 } |
| OLD | NEW |