Ejemplo n.º 1
0
  /** Do the real work of releaseAndFindNotifyTargets */
  Set<Locker> releaseAndFindNotifyTargetsInternal(long nodeId, Locker locker, int lockTableIndex) {
    Map<Long, Lock> lockTable = lockTables[lockTableIndex];
    Lock useLock = lockTable.get(nodeId);
    if (useLock == null) {
      useLock = lockTable.get(Long.valueOf(nodeId));
    }

    if (useLock == null) {
      /* Lock doesn't exist. */
      return null;
    }

    Set<Locker> lockersToNotify = useLock.release(locker, memoryBudget, lockTableIndex);
    if (lockersToNotify == null) {
      /* Not owner. */
      return null;
    }

    /* If it's not in use at all, remove it from the lock table. */
    if ((useLock.nWaiters() == 0) && (useLock.nOwners() == 0)) {
      lockTables[lockTableIndex].remove(nodeId);
      if (useLock.isThin()) {
        memoryBudget.updateLockMemoryUsage(REMOVE_TOTAL_THINLOCKIMPL_OVERHEAD, lockTableIndex);
      } else {
        memoryBudget.updateLockMemoryUsage(REMOVE_TOTAL_LOCKIMPL_OVERHEAD, lockTableIndex);
      }
    }

    return lockersToNotify;
  }