本文整理了Java中java.util.concurrent.locks.ReentrantReadWriteLock.getReadLockCount
方法的一些代码示例,展示了ReentrantReadWriteLock.getReadLockCount
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReentrantReadWriteLock.getReadLockCount
方法的具体详情如下:
包路径:java.util.concurrent.locks.ReentrantReadWriteLock
类名称:ReentrantReadWriteLock
方法名:getReadLockCount
[英]Queries the number of read locks held for this lock. This method is designed for use in monitoring system state, not for synchronization control.
[中]查询此锁的读取锁数。该方法设计用于监控系统状态,而不是用于同步控制。
代码示例来源:origin: apache/hbase
@VisibleForTesting
public int getReadLockCount() {
return lock.getReadLockCount();
}
代码示例来源:origin: OryxProject/oryx
@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());
}
代码示例来源:origin: cinchapi/concourse
/**
* 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();
}
代码示例来源:origin: cinchapi/concourse
/**
* 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();
}
代码示例来源:origin: cinchapi/concourse
@Override
public int getReadLockCount() {
return decorated.getReadLockCount();
}
代码示例来源:origin: org.apache.clerezza.commons-rdf/commons-rdf-impl-utils
@Override
public int getReadLockCount() {
return super.getReadLockCount();
}
代码示例来源:origin: org.terracotta.toolkit/terracotta-toolkit-1.3-impl
@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.");
}
}
代码示例来源:origin: org.terracotta.toolkit/terracotta-toolkit-1.4-impl
@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.");
}
}
代码示例来源:origin: espertechinc/esper
private static String getLockInfo(ReentrantReadWriteLock lock) {
String lockid = "RWLock@" + Integer.toHexString(lock.hashCode());
return lockid +
" readLockCount=" + lock.getReadLockCount() +
" isWriteLocked=" + lock.isWriteLocked();
}
代码示例来源:origin: com.espertech/com.springsource.com.espertech.esper
private static String getLockInfo(ReentrantReadWriteLock lock)
{
String lockid = "RWLock@" + Integer.toHexString(lock.hashCode());
return lockid +
" readLockCount=" + lock.getReadLockCount() +
" isWriteLocked=" + lock.isWriteLocked();
}
代码示例来源:origin: org.apache.clerezza/rdf.core.test
public static void checkIfReadLocked(ReentrantReadWriteLock lock) {
if (lock.getReadLockCount() == 0 && !lock.isWriteLockedByCurrentThread()) {
throw new RuntimeException("Neither read- nor write-locked");
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools
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();
}
}
}
}
代码示例来源:origin: winstonli/writelatex-git-bridge
private void trySignal() {
int threads = rwlock.getReadLockCount();
if (waiter != null && threads > 0) {
waiter.threadsRemaining(threads);
}
}
代码示例来源:origin: apache/clerezza
public static void checkIfReadLocked(ReentrantReadWriteLock lock) {
if (lock.getReadLockCount() == 0 && !lock.isWriteLockedByCurrentThread()) {
throw new RuntimeException("Neither read- nor write-locked");
}
}
代码示例来源:origin: org.rhq/rhq-core-plugin-container
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();
}
代码示例来源:origin: org.glassfish.main.common/glassfish-api
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");
}
}
代码示例来源:origin: eclipse-ee4j/glassfish
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");
}
}
代码示例来源:origin: org.terracotta.toolkit/terracotta-toolkit-1.4-impl
@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.");
}
}
代码示例来源:origin: org.terracotta.toolkit/terracotta-toolkit-1.3-impl
@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.");
}
}
代码示例来源:origin: cinchapi/concourse
@Override
public void afterReadUnlock(ReentrantReadWriteLock instance) {
if(instance.getReadLockCount() == 0) {
Iterable<Range<Value>> ranges = RangeTokens.convertToRange(token);
rangeLockService.info.remove(token.getKey(), ranges);
}
}
内容来源于网络,如有侵权,请联系作者删除!