Package 

Class LatchAwaiter


  • 
    public final class LatchAwaiter
    
                        

    This class allows blocking execution until asynchronous initialization or completion is signaled, with support for configurable timeouts and detailed logging for troubleshooting. It is designed for scenarios where certain tasks, such as SDK initialization, must finish before continuing. When used on the main/UI thread, it applies a shorter timeout and logs a thread stack trace to warn developers, helping to prevent Application Not Responding (ANR) errors caused by blocking the UI thread.

    Usage: val awaiter = LatchAwaiter("OneSignal SDK Init") awaiter.release() // when done

    • Constructor Summary

      Constructors 
      Constructor Description
      LatchAwaiter(String componentName)
    • Method Summary

      Modifier and Type Method Description
      final Unit release() Releases the latch to unblock any waiting threads.
      final Boolean await(Long timeoutMs) Wait for the latch to be released with an optional timeout.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LatchAwaiter

        LatchAwaiter(String componentName)
    • Method Detail

      • release

         final Unit release()

        Releases the latch to unblock any waiting threads.

      • await

         final Boolean await(Long timeoutMs)

        Wait for the latch to be released with an optional timeout.