IntervalLock (apache-cassandra API)
Date: 2018-02-14

org.apache.cassandra.utils.concurrent

## Class IntervalLock

- java.lang.Object
- - java.util.concurrent.locks.ReentrantReadWriteLock
  - - org.apache.cassandra.utils.concurrent.IntervalLock

- All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.locks.ReadWriteLock

      public class IntervalLock
      extends java.util.concurrent.locks.ReentrantReadWriteLock

  This class extends ReentrantReadWriteLock to provide a write lock that can only be acquired at provided intervals.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.util.concurrent.locks.ReentrantReadWriteLock

      `java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock, java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IntervalLock(TimeSource timeSource)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getLastIntervalAcquire()`
    `void` | `releaseIntervalLock()` Release the last acquired interval lock.
    `boolean` | `tryIntervalLock(long interval)` Try acquiring a write lock if the given interval is passed since the last call to this method.

    - ### Methods inherited from class java.util.concurrent.locks.ReentrantReadWriteLock

      `getOwner, getQueuedReaderThreads, getQueuedThreads, getQueuedWriterThreads, getQueueLength, getReadHoldCount, getReadLockCount, getWaitingThreads, getWaitQueueLength, getWriteHoldCount, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isWriteLocked, isWriteLockedByCurrentThread, readLock, toString, writeLock`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### IntervalLock

          public IntervalLock(TimeSource timeSource)

  - ### Method Detail

    - #### tryIntervalLock

          public boolean tryIntervalLock(long interval)

      Try acquiring a write lock if the given interval is passed since the last call to this method.
      Parameters:
        `interval` - In millis.
      Returns:
        True if acquired and locked, false otherwise.

    - #### releaseIntervalLock

          public void releaseIntervalLock()

      Release the last acquired interval lock.

    - #### getLastIntervalAcquire

          public long getLastIntervalAcquire()

Copyright © 2018 The Apache Software Foundation