Class ZModerator

java.lang.Object
org.spiderwiz.zutils.ZModerator

public class ZModerator
extends Object
A class used to moderate a repeated action according to a set rate.
  • Constructor Summary

    Constructors 
    Constructor Description
    ZModerator()  
  • Method Summary

    Modifier and Type Method Description
    void cleanup()
    Releases any thread that is paused by the moderator.
    void count()
    Counts one moderated step without pausing.
    protected int getRate()
    Returns the number of actions per minute that are set for the moderator.
    void moderate()
    Moderates one action.
    void reset()
    Resets the moderator for a new series of actions.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • reset

      public void reset()
      Resets the moderator for a new series of actions.
    • moderate

      public void moderate()
      Moderates one action.

      The method calculates the time that the moderated thread needs to wait until it can execute the next action and pauses the calling thread for that period.

    • count

      public void count()
      Counts one moderated step without pausing.
    • getRate

      protected int getRate()
      Returns the number of actions per minute that are set for the moderator.

      Override this method to set the moderator rate in actions per minute. The default is 30000 actions per minute.

      Returns:
      the number of actions per minute that are set for the moderator.
    • cleanup

      public void cleanup()
      Releases any thread that is paused by the moderator.