List of usage examples for java.util.concurrent.locks ReentrantLock getQueueLength
public final int getQueueLength()
From source file:io.tilt.minka.business.impl.SemaphoreImpl.java
private Permission checkState(final Action action) { if (action.getScope() == Scope.LOCAL) { final ReentrantLock lock = g(action); if (lock.isHeldByCurrentThread()) { logger.error("{}: {} lock already acquired by YOU ! CHECK YOUR CODE !", getClass().getSimpleName(), action);//from w ww . ja va 2 s .com return DENIED; //throw new RuntimeException("Come on check your code consistency pal !"); } else if (lock.isLocked()) { logger.error("{}: {} lock already acquired by {} thread ! and holds: {} more", getClass().getSimpleName(), action, lock.isHeldByCurrentThread() ? "current" : "sibling", lock.getQueueLength()); return DENIED; } } else if (action.getScope() == Scope.GLOBAL) { // TODO } // in the case of not being slave to those master to me or any (got that?) // i simply let them acquire, otherwise behead it ! for (final Entry<Action, Rule> entry : rules.entrySet()) { final List<Action> related = entry.getValue().getRelated(PARENT); if (!related.isEmpty()) { if (isLocked(entry.getKey()) && (related.contains(ANY) || related.contains(action))) { if (!rules.get(action).getRelated(CHILD).contains(entry.getKey())) { logger.warn( "{}: {} Cannot be acquired because not Child of previously acquired Parent lock: {}", getClass().getSimpleName(), action, entry.getKey()); return DENIED; } } } } return null; }