For avoiding lock during inserting to keep maxlen
321963
def _poplast(self):
        """"""

        try:
            tup = self.data.pop()
        except IndexError as ex:
            ex.args = ('DEPQ is already empty',)
            raise

        self_items = self.items

        try:
            self_items[tup[0]] -= 1
            if self_items[tup[0]] == 0:
                del self_items[tup[0]]
        except TypeError:
            r = repr(tup[0])
            self_items[r] -= 1
            if self_items[r] == 0:
                del self_items[r]

        return tup
867892
public void updateLockingValues(Object obj) throws PersistenceBrokerException
    {
        FieldDescriptor[] fields = getLockingFields();
        for (int i = 0; i < fields.length; i++)
        {
            FieldDescriptor fmd = fields[i];
            if (fmd.isUpdateLock())
            {
                PersistentField f = fmd.getPersistentField();
                Object cv = f.get(obj);
                // int
                if ((f.getType() == int.class) || (f.getType() == Integer.class))
                {
                    int newCv = 0;
                    if (cv != null)
                    {
                        newCv = ((Number) cv).intValue();
                    }
                    newCv++;
                    f.set(obj, new Integer(newCv));
                }
                // long
                else if ((f.getType() == long.class) || (f.getType() == Long.class))
                {
                    long newCv = 0;
                    if (cv != null)
                    {
                        newCv = ((Number) cv).longValue();
                    }
                    newCv++;
                    f.set(obj, new Long(newCv));
                }
                // Timestamp
                else if (f.getType() == Timestamp.class)
                {
                    long newCv = System.currentTimeMillis();
                    f.set(obj, new Timestamp(newCv));
                }
            }
        }
    }
711983
private void ensureCapacity (int n)    {
        if (n <= 0) {
            return;
        }
        int max;
        if (data == null || data.length == 0) {
            max = 25;
        }
        else if (data.length >= n * 5) {
            return;
        }
        else {
            max = data.length;
        }
        while (max < n * 5) {
            max *= 2;
        }

        String newData[] = new String[max];
        if (length > 0) {
            System.arraycopy(data, 0, newData, 0, length*5);
        }
        data = newData;
    }
52206
private long nextUnadjustedValue() throws FetchException, PersistException {
        if (mHasReservedValues) {
            long next = mNextValue + mIncrement;
            mNextValue = next;
            if (next < mStoredSequence.getNextValue()) {
                return next;
            }
            mHasReservedValues = false;
        }

        Transaction txn = mRepository.enterTopTransaction(null);
        txn.setForUpdate(true);
        try {
            // Assume that StoredSequence is stale, so reload.
            mStoredSequence.load();
            long next = mStoredSequence.getNextValue();
            long nextStored = next + mReserveAmount * mIncrement;

            if (next >= 0 && nextStored < 0) {
                // Wrapped around. There might be just a few values left.
                long avail = (Long.MAX_VALUE - next) / mIncrement;
                if (avail > 0) {
                    nextStored = next + avail * mIncrement;
                } else {
                    // Throw a PersistException since sequences are applied during
                    // insert operations, and inserts can only throw PersistExceptions.
                    throw new PersistException
                        ("Sequence exhausted: " + mStoredSequence.getName());
                }
            }

            mStoredSequence.setNextValue(nextStored);
            mStoredSequence.update();

            txn.commit();

            mNextValue = next;
            mHasReservedValues = true;
            return next;
        } finally {
            txn.exit();
        }
    }
431246
@Override
    public void setMaxRows(int max) throws SQLException
    {
        checkClosed();
        if (max < 0) {
            throw SQLError.get(SQLError.ILLEGAL_ARGUMENT, max);
        }
        this.maxRows = max;
    }
997889
@Override
    public void lock(Object entity, LockModeType lockMode)
    {
        ivEm.lock(entity, lockMode);
    }
1372100
private final void ensureCapacity(int len) {
        if (value.length < len) {
            value = new int[len];
            offset = 0;
            intLen = len;
        }
    }
754002
function keyIndexing(selector, maxLen, index) {
  var opts = resolverOpts(RESOLVE_MODE.KEY, maxLen, index);
  return resolveSelector(selector, opts);
}
132365
CompletableFuture<Boolean> handleMaxIdleExpireEntry(K key, V value, long maxIdle, boolean skipLocking) {
      return actualRemoveMaxIdleExpireEntry(key, value, maxIdle, skipLocking);
   }
710547
@Override
  protected void preInsert(MkMaxEntry entry) {
    KNNHeap knns_o = DBIDUtil.newHeap(getKmax());
    preInsert(entry, getRootEntry(), knns_o);
  }
1220386
def insert_at(position = 1)
      list_class.transaction do
        ids = lock_list!
        position = [[1, position].max, ids.size].min

        if persisted?
          current_position = ids.index(id) + 1

          sql = <<-SQL
            #{quoted_position_column} = CASE
            WHEN #{quoted_position_column} = #{current_position} THEN #{position}
            WHEN #{quoted_position_column} > #{current_position}
            AND #{quoted_position_column} <= #{position} THEN #{quoted_position_column} - 1
            WHEN #{quoted_position_column} < #{current_position}
            AND #{quoted_position_column} >= #{position} THEN #{quoted_position_column} + 1
            ELSE #{quoted_position_column}
            END
          SQL

          list_scope.update_all(sql)
          update_position(position)
        else
          save!

          sql = <<-SQL
            #{quoted_position_column} = CASE
            WHEN #{quoted_position_column} >= #{position} THEN #{quoted_position_column} + 1
            ELSE #{quoted_position_column}
            END
          SQL

          list_scope.update_all(sql)
          update_position(position)
        end
      end
    end
845917
function() {
		if (insertCounter === 3) {
			insertBtn.disabled = true;
		}
		else {
			insertBtn.disabled = false;
		}
		
		if (insertCounter === -3) {
			removeBtn.disabled = true;
		}
		else {
			removeBtn.disabled = false;
		}
	}
1267799
def forced_insert(self):
        
        # If we have any tokens we are waiting for
        if self.insert_till:
            # Determine where to append this token
            append_at = -1
            if self.inserted_line:
                append_at = -self.inserted_line+1

            # Reset insert_till if we found it
            if self.current.tokenum == self.insert_till[0] and self.current.value == self.insert_till[1]:
                self.insert_till = None
            else:
                # Adjust self.adjust_indent_at to take into account the new token
                for index, value in enumerate(self.adjust_indent_at):
                    if value < len(self.result) - append_at:
                        self.adjust_indent_at[index] = value + 1

                # Insert the new token
                self.result.insert(append_at, (self.current.tokenum, self.current.value))

            # We appended the token
            return True
1311326
function updateIsLocked(isLocked, oldValue) {
      scope.isLockedOpen = isLocked;
      if (isLocked === oldValue) {
        element.toggleClass('md-locked-open', !!isLocked);
      } else {
        $animate[isLocked ? 'addClass' : 'removeClass'](element, 'md-locked-open');
      }
      if (backdrop) {
        backdrop.toggleClass('md-locked-open', !!isLocked);
      }
    }
1289008
public void bindInsert(PreparedStatement stmt, ClassDescriptor cld, Object obj) throws java.sql.SQLException
    {
        ValueContainer[] values;
        cld.updateLockingValues(obj); // BRJ : provide useful defaults for locking fields

        if (cld.getInsertProcedure() != null)
        {
            this.bindProcedure(stmt, cld, obj, cld.getInsertProcedure());
        }
        else
        {
            values = getAllValues(cld, obj);
            for (int i = 0; i < values.length; i++)
            {
                setObjectForStatement(stmt, i + 1, values[i].getValue(), values[i].getJdbcType().getType());
            }
        }
    }
563580
private void lock(Object obtainer) throws PSQLException {
    if (lockedFor == obtainer) {
      throw new PSQLException(GT.tr("Tried to obtain lock while already holding it"),
          PSQLState.OBJECT_NOT_IN_STATE);

    }
    waitOnLock();
    lockedFor = obtainer;
  }
1360256
private void lockInodeInternal(Inode inode, LockMode mode) {
    Preconditions.checkState(!endsInInode());
    String lastEdgeName = ((EdgeEntry) lastEntry()).getEdge().getName();
    Preconditions.checkState(inode.getName().equals(lastEdgeName),
        "Expected to lock inode %s but locked inode %s", lastEdgeName, inode.getName());

    mLockedInodes.add(inode);
    mEntries.add(new InodeEntry(mInodeLockManager.lockInode(inode, mode), inode));
  }