Package 

Class WorkerHandler


  • 
    public class WorkerHandler
    
                        

    Class holding a background handler. We want them to survive configuration changes if there's still job to do.

    • Method Detail

      • execute

         static void execute(@NonNull() Runnable action)

        Handy utility to perform an action in a fallback thread.Not to be used for long-running operations since they will blockthe fallback thread.

        Parameters:
        action - the action
      • run

         void run(@NonNull() Runnable runnable)

        Post an action on this handler.

        Parameters:
        runnable - the action
      • run

         <T> Task<T> run(@NonNull() Callable<T> callable)

        Post an action on this handler.

        Parameters:
        callable - the action
      • post

         void post(@NonNull() Runnable runnable)

        Post an action on this handler.

        Parameters:
        runnable - the action
      • post

         <T> Task<T> post(@NonNull() Callable<T> callable)

        Post an action on this handler.

        Parameters:
        callable - the action
      • post

         void post(long delay, @NonNull() Runnable runnable)

        Post an action on this handler.

        Parameters:
        delay - the delay in millis
        runnable - the action
      • remove

         void remove(@NonNull() Runnable runnable)

        Removes a previously added action from this handler.

        Parameters:
        runnable - the action
      • destroy

         void destroy()

        Destroys this handler and its thread. After this method returns, the handlershould be considered unusable.Internal note: this does not remove the thread from our cache, but it doesinterrupt it, so the next get call will remove it.In any case, we only store weak references.

      • destroyAll

         static void destroyAll()

        Destroys all handlers, interrupting their work andremoving them from our cache.