Class FixedIntervalInvocationGate

    • Method Detail

      • isTooSoon

        public boolean isTooSoon​(long currentTime)
        Returns true if the caller should skip further work; false if this call is allowed to proceed.

        If currentTime is InvocationGate.TIME_UNAVAILABLE (-1), this method returns false so the caller can still perform the work when the clock is unavailable.

        Otherwise, when currentTime is strictly before the next allowed time, the method returns true (too soon). When currentTime has reached the next allowed time, this thread tries to advance that time by increment. On success it returns false (proceed); if another thread already advanced it, this thread returns true so that only one passage per interval is granted.

        Specified by:
        isTooSoon in interface InvocationGate
        Parameters:
        currentTime - current time in milliseconds, or InvocationGate.TIME_UNAVAILABLE if unknown
        Returns:
        true if further work should be skipped; false if the caller may proceed