当前位置: 首页>>代码示例>>Java>>正文


Java Condition.awaitUninterruptibly方法代码示例

本文整理汇总了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();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:18,代码来源:MultiLock.java

示例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();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:18,代码来源:MultiLock.java

示例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();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:57,代码来源:ShortCircuitCache.java


注:本文中的java.util.concurrent.locks.Condition.awaitUninterruptibly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。