Package com.telnyx.webrtc.lib
Class ThreadUtils
java.lang.Object
com.telnyx.webrtc.lib.ThreadUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceUtility interface to be used with executeUninterruptibly() to wait for blocking operations to complete without getting interrupted..static classUtility class to be used for checking that a method is called on the correct thread. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic booleanawaitUninterruptibly(CountDownLatch barrier, long timeoutMs) static voidThrows exception if called from other than main thread.static voidUtility method to make sure a blocking operation is executed to completion without getting interrupted.static voidinvokeAtFrontUninterruptibly(Handler handler, Runnable runner) Post `runner` to `handler`, at the front, and wait for completion.static <V> VinvokeAtFrontUninterruptibly(Handler handler, Callable<V> callable) Post `callable` to `handler` and wait for the result.static voidjoinUninterruptibly(Thread thread) static booleanjoinUninterruptibly(Thread thread, long timeoutMs)
-
Constructor Details
-
ThreadUtils
public ThreadUtils()
-
-
Method Details
-
checkIsOnMainThread
public static void checkIsOnMainThread()Throws exception if called from other than main thread. -
executeUninterruptibly
Utility method to make sure a blocking operation is executed to completion without getting interrupted. This should be used in cases where the operation is waiting for some critical work, e.g. cleanup, that must complete before returning. If the thread is interrupted during the blocking operation, this function will re-run the operation until completion, and only then re-interrupt the thread. -
joinUninterruptibly
-
joinUninterruptibly
-
awaitUninterruptibly
-
awaitUninterruptibly
-
invokeAtFrontUninterruptibly
Post `callable` to `handler` and wait for the result. -
invokeAtFrontUninterruptibly
Post `runner` to `handler`, at the front, and wait for completion.
-