@VisibleForTesting public int getReadLockCount() { return lock.getReadLockCount(); }
@Test public void testReadLock() { ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); AutoReadWriteLock al = new AutoReadWriteLock(lock); assertEquals(0, lock.getReadLockCount()); try (AutoLock al2 = al.autoReadLock()) { assertEquals(1, lock.getReadLockCount()); } assertEquals(0, lock.getReadLockCount()); }
/** * Return the number write locks held for this lock. This method is designed * for use in monitoring systems, not for synchronization control. * * @return the number of write locks held */ public int getWriteLockCount() { return writers.getReadLockCount(); }
/** * Return the number read locks held for this lock. This method is designed * for use in monitoring systems, not for synchronization control. * * @return the number of read locks held */ public int getReadLockCount() { return readers.getReadLockCount(); }
@Override public int getReadLockCount() { return decorated.getReadLockCount(); }
@Override public int getReadLockCount() { return super.getReadLockCount(); }
@SuppressWarnings("unused") private void onShare() { if (lock.localLock().getReadLockCount() > 0) { throw new IllegalStateException("You are attempting to share a TerracottaReadWriteLock.ReadLock when it is in a locked state. " + "Locks cannot be shared while locked."); } }
@SuppressWarnings("unused") private void onShare() { if (lock.localLock().getReadLockCount() > 0) { throw new IllegalStateException("You are attempting to share a TerracottaReadWriteLock.ReadLock when it is in a locked state. " + "Locks cannot be shared while locked."); } }
private static String getLockInfo(ReentrantReadWriteLock lock) { String lockid = "RWLock@" + Integer.toHexString(lock.hashCode()); return lockid + " readLockCount=" + lock.getReadLockCount() + " isWriteLocked=" + lock.isWriteLocked(); }
private static String getLockInfo(ReentrantReadWriteLock lock) { String lockid = "RWLock@" + Integer.toHexString(lock.hashCode()); return lockid + " readLockCount=" + lock.getReadLockCount() + " isWriteLocked=" + lock.isWriteLocked(); }
public static void checkIfReadLocked(ReentrantReadWriteLock lock) { if (lock.getReadLockCount() == 0 && !lock.isWriteLockedByCurrentThread()) { throw new RuntimeException("Neither read- nor write-locked"); } }
private void notifyUpgradingThread() { if (shouldTryAtomicUpgrade && tryingLockUpgrade.get()) { synchronized (highPriorityMonitor) { if (lock.getReadLockCount() < 2 && !lock.isWriteLocked()) { // all the read locks, except the one of the thread that is trying to upgrade its lock, have been released highPriorityMonitor.notifyAll(); } } } }
private void trySignal() { int threads = rwlock.getReadLockCount(); if (waiter != null && threads > 0) { waiter.threadsRemaining(threads); } }
public static void checkIfReadLocked(ReentrantReadWriteLock lock) { if (lock.getReadLockCount() == 0 && !lock.isWriteLockedByCurrentThread()) { throw new RuntimeException("Neither read- nor write-locked"); } }
private String getFacetLockStatus() { StringBuilder str = new StringBuilder("Facet lock status for ["); str.append(getResource()); str.append("], is-write-locked=[").append(facetAccessLock.isWriteLocked()); str.append("], is-write-locked-by-current-thread=[").append(facetAccessLock.isWriteLockedByCurrentThread()); str.append("], read-locks=[").append(facetAccessLock.getReadLockCount()); str.append("], waiting-for-lock-queue-size=[").append(facetAccessLock.getQueueLength()); str.append("]"); return str.toString(); }
public void dumpState(Logger logger, Level level) { if (logger.isLoggable(level)) { logger.log(level, "Current locking conditions are " + rwlock.getReadLockCount() + "/"+ rwlock.getReadHoldCount() + " shared locks" + "and " + rwlock.getWriteHoldCount() + " write lock"); } }
public void dumpState(Logger logger, Level level) { if (logger.isLoggable(level)) { logger.log(level, "Current locking conditions are " + rwlock.getReadLockCount() + "/"+ rwlock.getReadHoldCount() + " shared locks" + "and " + rwlock.getWriteHoldCount() + " write lock"); } }
@SuppressWarnings("unused") private void onShare() { if ((localLock().getReadLockCount() > 0) || localLock().isWriteLocked()) { throw new IllegalStateException("You are attempting to share a TerracottaReadWriteLock when it is in a locked state. " + "Locks cannot be shared while locked."); } }
@SuppressWarnings("unused") private void onShare() { if ((localLock().getReadLockCount() > 0) || localLock().isWriteLocked()) { throw new IllegalStateException("You are attempting to share a TerracottaReadWriteLock when it is in a locked state. " + "Locks cannot be shared while locked."); } }
@Override public void afterReadUnlock(ReentrantReadWriteLock instance) { if(instance.getReadLockCount() == 0) { Iterable<Range<Value>> ranges = RangeTokens.convertToRange(token); rangeLockService.info.remove(token.getKey(), ranges); } }