Class MainThreadValidatorUtil


  • public final class MainThreadValidatorUtil
    extends Object
    This utility exists to bridge between the visibility of the currentMainThread field in the RpcEndpoint.

    The currentMainThread can be hidden from RpcEndpoint implementations and only be accessed via this utility from other packages.

    • Constructor Detail

      • MainThreadValidatorUtil

        public MainThreadValidatorUtil​(RpcEndpoint endpoint)
    • Method Detail

      • enterMainThread

        public void enterMainThread()
      • exitMainThread

        public void exitMainThread()
      • isRunningInExpectedThread

        public static boolean isRunningInExpectedThread​(@Nullable
                                                        Thread expected)
        Returns true iff the current thread is equals to the provided expected thread and logs violations.
        Parameters:
        expected - the expected main thread.
        Returns:
        true iff the current thread is equals to the provided expected thread.