Class TriggerRepeat


  • public class TriggerRepeat
    extends java.lang.Object
    Trigger an action and repeat it as long as it keeps being triggered. General purpose is to start a background thread but let it keep repeating until there no more triggers were received in the mean time.

    For example, you detect a change in the file system and then need to synchronize a persistent structure. The trigger() call will return the true the first time, indicating that a background thread should be started. The background tasks does it works and checks the doit() at the end. If it returns true, it restarts, else it returns.

    • Constructor Summary

      Constructors 
      Constructor Description
      TriggerRepeat()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean doit()
      Query if the action should be executed.
      boolean trigger()
      Trigger the action, returns true if there was no action.
      • Methods inherited from class java.lang.Object

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

      • TriggerRepeat

        public TriggerRepeat()
    • Method Detail

      • trigger

        public boolean trigger()
        Trigger the action, returns true if there was no action.
        Returns:
        true if there was no action
      • doit

        public boolean doit()
        Query if the action should be executed. The action should be executed if there are have been more trigger() calls after the doit() call. After this call, triggers == doits. I.e. it coalesces multiple triggers.
        Returns:
        true of the the triggers != dots