Class TimeoutScheduler

    • Constructor Detail

      • TimeoutScheduler

        public TimeoutScheduler​(com.forgerock.opendj.util.ReferenceCountedObject.Reference<ScheduledExecutorService> scheduler,
                                Duration period)
        Creates a new TimeoutScheduler.
        Parameters:
        scheduler - The scheduler that will be used for periodically checking for timeouts.
        period - The period between successive executions. A period of 0 will never invoke the scheduled tasks, regardless of the underlying time unit.
    • Method Detail

      • scheduleAtFixedRate

        public void scheduleAtFixedRate​(TimeoutScheduler.TimeoutEventListener task)
        Schedules the task for periodic invocation.

        Note that there is no delay guaranteed for the first invocation: the first invocation can be invoked immediately or at most twice the period. Subsequent invocations should happen at the specified period.

        Parameters:
        task - The task to register for periodic invocation.
        Throws:
        IllegalStateException - If this scheduler is closed.
        NullPointerException - If task is null.
      • removeScheduledTask

        public boolean removeScheduledTask​(TimeoutScheduler.TimeoutEventListener task)
        De-registers a task for periodic invocation.

        Note that the task might be invoked a last time after this method returns.

        Parameters:
        task - The task to de-register.
        Returns:
        true if the task was de-registered, false is the task was not registered.
        Throws:
        NullPointerException - If task is null.
      • getPeriodMillis

        public long getPeriodMillis()
        Returns the period in milliseconds between successive task invocations.
        Returns:
        The period in milliseconds or 0 if tasks are never invoked.
      • now

        public long now()
        Returns the current time in milliseconds from the Clock of this TimeoutScheduler.
        Returns:
        The current time in milliseconds.