Class DefaultRetryLatch

    • Constructor Detail

      • DefaultRetryLatch

        public DefaultRetryLatch()
    • Method Detail

      • open

        public void open​(long expectedEra)
        Description copied from interface: RetryLatch
        Opens this latch only if the expectedEra is the same. If the expectedEra is not the same, the call is ignored. If the Latch already is open, this call is also ignored.
        Specified by:
        open in interface RetryLatch
        Parameters:
        expectedEra - the expected era.
      • await

        public void await​(long expectedEra,
                          String transactionFamilyName)
        Description copied from interface: RetryLatch
        Awaits for this Latch to open. There are 3 possible ways for this methods to complete;
        1. the era doesn't match the expected era
        2. the latch is opened while waiting
        3. the latch is interrupted while waiting. When this happens the RetryInterruptedException is thrown and the Thread.interrupt status is restored.
        Specified by:
        await in interface RetryLatch
        Parameters:
        expectedEra - the expected era.
        transactionFamilyName - the name of the transaction (only needed for creating a usable message in the RetryInterruptedException).
      • awaitUninterruptible

        public void awaitUninterruptible​(long expectedEra)
        Description copied from interface: RetryLatch
        Awaits for this latch to open. This call is not responsive to interrupts.
        Specified by:
        awaitUninterruptible in interface RetryLatch
        Parameters:
        expectedEra - the expected era. If the era is different, the await always succeeds.
      • awaitNanosUninterruptible

        public long awaitNanosUninterruptible​(long expectedEra,
                                              long nanosTimeout)
        Description copied from interface: RetryLatch
        Awaits for this latch to open with a timeout. This call is not responsive to interrupts.

        When the calling thread is interrupted, the Thread.interrupt status will not be eaten by this method and safely be restored.

        Specified by:
        awaitNanosUninterruptible in interface RetryLatch
        Parameters:
        expectedEra - the expected era.
        nanosTimeout - the timeout in nanoseconds
        Returns:
        the remaining timeout. A negative value indicates that the Latch is not opened in time.
      • awaitNanos

        public long awaitNanos​(long expectedEra,
                               long nanosTimeout,
                               String transactionFamilyName)
        Description copied from interface: RetryLatch
        Awaits for this latch to open with a timeout. This call is responsive to interrupts.

        When the calling thread is interrupted, the Thread.interrupt status will not be eaten by this method and safely be restored.

        Specified by:
        awaitNanos in interface RetryLatch
        Parameters:
        expectedEra - the expected era
        nanosTimeout - the timeout in nanoseconds. Can safely be called with a zero or negative timeout
        transactionFamilyName - the name of the transaction (only needed for creating a usable message in the RetryInterruptedException).
        Returns:
        the remaining timeout. A 0 or negative value indicates that the latch is not opened in time.
      • getEra

        public long getEra()
        Description copied from interface: RetryLatch
        Gets the current era.
        Specified by:
        getEra in interface RetryLatch
        Returns:
        the current era.
      • reset

        public void reset()
        Description copied from interface: RetryLatch
        Prepares the Latch for pooling. All waiting threads will be notified and the era is increased.
        Specified by:
        reset in interface RetryLatch
      • isOpen

        public boolean isOpen()
        Description copied from interface: RetryLatch
        Checks if the Latch is open.
        Specified by:
        isOpen in interface RetryLatch
        Returns:
        true if the Latch is open, false otherwise.