| Index: talk/app/webrtc/java/android/org/webrtc/ThreadUtils.java
|
| diff --git a/talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java b/talk/app/webrtc/java/android/org/webrtc/ThreadUtils.java
|
| similarity index 63%
|
| copy from talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java
|
| copy to talk/app/webrtc/java/android/org/webrtc/ThreadUtils.java
|
| index f7032a739bdbb24ac93dc000b9a42fb11223cc40..d57ff65bb4783003a8ffc5fc4d9b257d1421f506 100644
|
| --- a/talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java
|
| +++ b/talk/app/webrtc/java/android/org/webrtc/ThreadUtils.java
|
| @@ -27,31 +27,27 @@
|
|
|
| package org.webrtc;
|
|
|
| -public class CallSessionFileRotatingLogSink {
|
| - static {
|
| - System.loadLibrary("jingle_peerconnection_so");
|
| - }
|
| -
|
| - private long nativeSink;
|
| -
|
| - public static byte[] getLogData(String dirPath) {
|
| - return nativeGetLogData(dirPath);
|
| - }
|
| -
|
| - public CallSessionFileRotatingLogSink(
|
| - String dirPath, int maxFileSize, Logging.Severity severity) {
|
| - nativeSink = nativeAddSink(dirPath, maxFileSize, severity.ordinal());
|
| - }
|
| -
|
| - public void dispose() {
|
| - if (nativeSink != 0) {
|
| - nativeDeleteSink(nativeSink);
|
| - nativeSink = 0;
|
| +public class ThreadUtils {
|
| + /**
|
| + * Helper function to make sure a thread is joined without getting interrupted. This should be
|
| + * used in cases where |thread| is doing some critical work, e.g. cleanup, that must complete
|
| + * before returning. The thread interruption flag is set if an interrupt occurs during join().
|
| + */
|
| + public static void joinUninterruptibly(Thread thread) {
|
| + boolean wasInterrupted = false;
|
| + while (true) {
|
| + try {
|
| + thread.join();
|
| + break;
|
| + } catch (InterruptedException e) {
|
| + // Someone is asking us to return early at our convenience. We can't cancel this join(),
|
| + // but we should preserve the information and pass it along.
|
| + wasInterrupted = true;
|
| + }
|
| + }
|
| + // Pass interruption information along.
|
| + if (wasInterrupted) {
|
| + Thread.currentThread().interrupt();
|
| }
|
| }
|
| -
|
| - private static native long nativeAddSink(
|
| - String dirPath, int maxFileSize, int severity);
|
| - private static native void nativeDeleteSink(long nativeSink);
|
| - private static native byte[] nativeGetLogData(String dirPath);
|
| }
|
|
|