本文整理汇总了Java中java.util.concurrent.locks.Condition.awaitUninterruptibly方法的典型用法代码示例。如果您正苦于以下问题:Java Condition.awaitUninterruptibly方法的具体用法?Java Condition.awaitUninterruptibly怎么用?Java Condition.awaitUninterruptibly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.locks.Condition
的用法示例。
在下文中一共展示了Condition.awaitUninterruptibly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lockAll
import java.util.concurrent.locks.Condition; //导入方法依赖的package包/类
public UnlockAll lockAll() {
iLock.lock();
try {
iLog.debug("Locking all ...");
while (iAllLocked != null)
iAllLocked.awaitUninterruptibly();
iAllLocked = iLock.newCondition();
while (!iIndividualLocks.isEmpty()) {
Condition otherCondition = iIndividualLocks.values().iterator().next();
otherCondition.awaitUninterruptibly();
}
iLog.debug("Locked: all");
return new UnlockAll();
} finally {
iLock.unlock();
}
}
示例2: lock
import java.util.concurrent.locks.Condition; //导入方法依赖的package包/类
public Unlock lock(Collection<Long> ids) {
iLock.lock();
try {
if (ids == null || ids.isEmpty()) return new Unlock(ids);
iLog.debug("Locking " + ids + " ...");
Condition otherCondition = null;
while ((otherCondition = hasLock(ids)) != null)
otherCondition.awaitUninterruptibly();
Condition myCondition = iLock.newCondition();
for (Long id: ids)
iIndividualLocks.put(id, myCondition);
iLog.debug("Locked: " + ids);
return new Unlock(ids);
} finally {
iLock.unlock();
}
}
示例3: getOrCreateClientMmap
import java.util.concurrent.locks.Condition; //导入方法依赖的package包/类
ClientMmap getOrCreateClientMmap(ShortCircuitReplica replica,
boolean anchored) {
Condition newCond;
lock.lock();
try {
while (replica.mmapData != null) {
if (replica.mmapData instanceof MappedByteBuffer) {
ref(replica);
MappedByteBuffer mmap = (MappedByteBuffer)replica.mmapData;
return new ClientMmap(replica, mmap, anchored);
} else if (replica.mmapData instanceof Long) {
long lastAttemptTimeMs = (Long)replica.mmapData;
long delta = Time.monotonicNow() - lastAttemptTimeMs;
if (delta < mmapRetryTimeoutMs) {
if (LOG.isTraceEnabled()) {
LOG.trace(this + ": can't create client mmap for " +
replica + " because we failed to " +
"create one just " + delta + "ms ago.");
}
return null;
}
if (LOG.isTraceEnabled()) {
LOG.trace(this + ": retrying client mmap for " + replica +
", " + delta + " ms after the previous failure.");
}
} else if (replica.mmapData instanceof Condition) {
Condition cond = (Condition)replica.mmapData;
cond.awaitUninterruptibly();
} else {
Preconditions.checkState(false, "invalid mmapData type %s",
replica.mmapData.getClass().getName());
}
}
newCond = lock.newCondition();
replica.mmapData = newCond;
} finally {
lock.unlock();
}
MappedByteBuffer map = replica.loadMmapInternal();
lock.lock();
try {
if (map == null) {
replica.mmapData = Long.valueOf(Time.monotonicNow());
newCond.signalAll();
return null;
} else {
outstandingMmapCount++;
replica.mmapData = map;
ref(replica);
newCond.signalAll();
return new ClientMmap(replica, map, anchored);
}
} finally {
lock.unlock();
}
}