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
-
-
Constructor Summary
Constructors Constructor Description IntervalLock(TimeSource timeSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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
-
-
-
-
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()
-
-