Class PeriodicGroupRunnable

  • All Implemented Interfaces:
    ScheduleableGroupAction, TaskRunnable, Runnable
    Direct Known Subclasses:
    FSRequestCleanUpRunnable, PeriodicGroupMap

    public class PeriodicGroupRunnable
    extends PeriodicRunnable
    implements ScheduleableGroupAction
    Periodic task (task will be run periodically) which has handler separated (share the same ScheduleableGroupAction) can be scheduled to Timer or TimerPool by using PeriodicGroupRunnable. All the elements in the same PeriodicGroupRunnable must have the same timeout period and run period. Elements will be grouped by using the time they enter PeriodicGroupRunnable. ScheduleableGroupAction will only go through the elements which entered PeriodicGroupRunnable excess the timeout time.
    • Constructor Detail

      • PeriodicGroupRunnable

        public PeriodicGroupRunnable​(ScheduleableGroupAction target,
                                     long runPeriod,
                                     long timeoutPeriod,
                                     boolean removeElementAfterAction)
                              throws IllegalArgumentException
        Constructor of PeriodicGroupRunnable.
        Parameters:
        target - The ScheduleableGroupAction interface to be run on the objects when there is time
        runPeriod - Run period in ms
        timeoutPeriod - timeout period in ms
        removeElementAfterAction - Whether to remove the elements after running the ScheduleableGroupAction on the objects
        Throws:
        IllegalArgumentException
    • Method Detail

      • doGroupAction

        public void doGroupAction​(Object obj)
        The function to be run on the objects when there is time.
        Specified by:
        doGroupAction in interface ScheduleableGroupAction
        Parameters:
        obj - The object the function act on
      • run

        public void run()
        Implements for TaskRunnable. Run the function of ScheduleableGroupAction on the objects in thisTurn 1 by 1, and interchange thisTurn and nextTurn.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class PeriodicRunnable