Unpins the specified buffer. If the buffer's pin count becomes 0, then
the threads on the wait list are notified.

@param buff
the buffer to be unpinned
771412
public void unpin(Buffer buff) {
		BlockId blk = buff.block();
		PinnedBuffer pinnedBuff = pinnedBuffers.get(blk);
		
		if (pinnedBuff != null) {
			pinnedBuff.pinnedCount--;
			
			if (pinnedBuff.pinnedCount == 0) {
				bufferPool.unpin(buff);
				pinnedBuffers.remove(blk);
				
				synchronized (bufferPool) {
					bufferPool.notifyAll();
				}
			}
		}
	}
45687
@Override
    public void unread( char[] cbuf, int off, int len ) throws IOException {
        assert len >= 0;
        assert off >= 0;

        final int endIndex = off + len;
        for ( int index = endIndex - 1; index >= off; index-- ) {
            unread( cbuf[ index ] );
        }
    }
643652
protected void releasing(ByteBuffer buffer) {
        if (buffer != null && buffer.isDirect()) {
            DirectByteBufferHelper directByteBufferHelper = this.directByteBufferHelper.get();
            if (directByteBufferHelper != null) {
                directByteBufferHelper.releaseDirectByteBuffer(buffer);
            }
        }
    }
664313
private int parse(final IntBuffer buff, final int start) {
        int pos = start;

        /**
         * Revision (1 byte): An unsigned 8-bit value that specifies the revision of the SECURITY_DESCRIPTOR
         * structure. This field MUST be set to one.
         */
        final byte[] header = NumberFacility.getBytes(buff.get(pos));
        revision = header[0];

        /**
         * Control (2 bytes): An unsigned 16-bit field that specifies control access bit flags. The Self Relative
         * (SR) bit MUST be set when the security descriptor is in self-relative format.
         */
        controlFlags = new byte[] { header[3], header[2] };
        final boolean[] controlFlag = NumberFacility.getBits(controlFlags);

        pos++;
        /**
         * OffsetOwner (4 bytes): An unsigned 32-bit integer that specifies the offset to the SID. This SID
         * specifies the owner of the object to which the security descriptor is associated. This must be a valid
         * offset if the OD flag is not set. If this field is set to zero, the OwnerSid field MUST not be present.
         */
        if (!controlFlag[15]) {
            offsetOwner = NumberFacility.getReverseUInt(buff.get(pos));
        } else {
            offsetOwner = 0;
        }

        pos++;

        /**
         * OffsetGroup (4 bytes): An unsigned 32-bit integer that specifies the offset to the SID. This SID
         * specifies the group of the object to which the security descriptor is associated. This must be a valid
         * offset if the GD flag is not set. If this field is set to zero, the GroupSid field MUST not be present.
         */
        if (!controlFlag[14]) {
            offsetGroup = NumberFacility.getReverseUInt(buff.get(pos));
        } else {
            offsetGroup = 0;
        }

        pos++;

        /**
         * OffsetSacl (4 bytes): An unsigned 32-bit integer that specifies the offset to the ACL that contains
         * system ACEs. Typically, the system ACL contains auditing ACEs (such as SYSTEM_AUDIT_ACE,
         * SYSTEM_AUDIT_CALLBACK_ACE, or SYSTEM_AUDIT_CALLBACK_OBJECT_ACE), and at most one Label ACE (as specified
         * in section 2.4.4.13). This must be a valid offset if the SP flag is set; if the SP flag is not set, this
         * field MUST be set to zero. If this field is set to zero, the Sacl field MUST not be present.
         */
        if (controlFlag[11]) {
            offsetSACL = NumberFacility.getReverseUInt(buff.get(pos));
        } else {
            offsetSACL = 0;
        }

        pos++;

        /**
         * OffsetDacl (4 bytes): An unsigned 32-bit integer that specifies the offset to the ACL that contains ACEs
         * that control access. Typically, the DACL contains ACEs that grant or deny access to principals or groups.
         * This must be a valid offset if the DP flag is set; if the DP flag is not set, this field MUST be set to
         * zero. If this field is set to zero, the Dacl field MUST not be present.
         */
        if (controlFlag[13]) {
            offsetDACL = NumberFacility.getReverseUInt(buff.get(pos));
        } else {
            offsetDACL = 0;
        }

        /**
         * OwnerSid (variable): The SID of the owner of the object. The length of the SID MUST be a multiple of 4.
         * This field MUST be present if the OffsetOwner field is not zero.
         */
        if (offsetOwner > 0) {
            pos = (int) (offsetOwner / 4);
            // read for OwnerSid
            owner = new SID();
            pos = owner.parse(buff, pos);
        }

        /**
         * GroupSid (variable): The SID of the group of the object. The length of the SID MUST be a multiple of 4.
         * This field MUST be present if the GroupOwner field is not zero.
         */
        if (offsetGroup > 0) {
            // read for GroupSid
            pos = (int) (offsetGroup / 4);
            group = new SID();
            pos = group.parse(buff, pos);
        }

        /**
         * Sacl (variable): The SACL of the object. The length of the SID MUST be a multiple of 4. This field MUST
         * be present if the SP flag is set.
         */
        if (offsetSACL > 0) {
            // read for Sacl
            pos = (int) (offsetSACL / 4);
            sacl = new ACL();
            pos = sacl.parse(buff, pos);
        }

        /**
         * Dacl (variable): The DACL of the object. The length of the SID MUST be a multiple of 4. This field MUST
         * be present if the DP flag is set.
         */
        if (offsetDACL > 0) {
            pos = (int) (offsetDACL / 4);
            dacl = new ACL();
            pos = dacl.parse(buff, pos);
        }

        return pos;
    }
877399
private void removeBuffer(W buffer) {
        createdBufs.decrementAndGet();
        if (bufferMonitor.remove(buffer) == null) {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.WARNING,
                    "Attempt to remove unknown buffer from pool.",
                    new Throwable());
            } else {
                logger.warning("Attempt to remove unknown buffer from pool.");
            }
        }
    }
617240
public static void flip(WsByteBuffer[] list) {
        if (list != null) {
            for (int i = 0; i < list.length; i++) {
                if (list[i] != null) {
                    list[i].flip();
                }
            }
        }
    }
821936
public void release(PooledWsByteBufferImpl buffer) {
        if (inUseTable != null) {
            inUseTable.remove(buffer);
        }
        boolean pooled = pool.put(buffer);
        if (isDirectPool && !pooled) {
            destroy(buffer);
        }
    }
1158899
@SuppressWarnings("unchecked")
    // The warning 'unchecked cast' being suppressed here comes from the build() formally returning
    // a MessageLite-derived class that cannot be statically guaranteed to be the MessageType.
    private void deserializeMessage(ByteBuffer buff) throws Exception {
        MessageType msg = (MessageType) prototype.newBuilderForType().mergeFrom(ByteString.copyFrom(buff)).build();
        resetTimeout();
        handler.messageReceived(this, msg);
    }
441226
public void release() throws IOException {
    for (BufferPool.Buffer b: buffers) {
      PooledBuffers.release(b);
    }

    buffers.clear();
    count = 0;
  }
358061
private void stop(boolean removeFromList) {
        synchronized (lock) {
            observing = false;
            willUpdate = false; // cancels the delayed update started by -databaseChanged
            if (query != null && query.getDatabase() != null && dbListenerToken != null) {
                query.getDatabase().removeChangeListener(dbListenerToken);
                dbListenerToken = null;
            }
            if (removeFromList && query != null && query.getDatabase() != null) {
                query.getDatabase().getActiveLiveQueries().remove(this);
            }
            releaseResultSet();
        }
    }
1312981
public synchronized void unsynchronizeWith(UpdateSynchronizer oldsync) {
    if(synchronizer == null) {
      LoggingUtil.warning("Warning: was not synchronized.");
      return;
    }
    if(synchronizer != oldsync) {
      LoggingUtil.warning("Warning: was synchronized differently!");
      return;
    }
    // LoggingUtil.warning("Unsynchronizing: " + sync + " " + oldsync);
    synchronizer = null;
    runQueue();
  }
1335611
private final void contendedLock() {
            boolean waiting = false;
            for (int s;;) {
                if (((s = lockState) & ~WAITER) == 0) {
                    if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) {
                        if (waiting)
                            waiter = null;
                        return;
                    }
                }
                else if ((s & WAITER) == 0) {
                    if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) {
                        waiting = true;
                        waiter = Thread.currentThread();
                    }
                }
                else if (waiting)
                    LockSupport.park(this);
            }
        }
1003272
public void unqueueBuffers (Buffer... buffers)
    {
        IntBuffer idbuf = BufferUtils.createIntBuffer(buffers.length);
        for (int ii = 0; ii < buffers.length; ii++) {
            Buffer buffer = buffers[ii];
            _queue.remove(buffer);
            idbuf.put(ii, buffer.getId());
        }
        AL10.alSourceUnqueueBuffers(_id, idbuf);
    }
429495
@Override
    public void setState(PowerState state) {
        switch(state) {
            case OFF: {
                if(!isOff()) {

                    // apply the new pin state
                    pin.setState(offState);
                }
                break;
            }
            case ON: {
                if(!isOn()) {

                    // apply the new pin state
                    pin.setState(onState);
                }
                break;
            }
            default: {
                throw new UnsupportedOperationException("Cannot set power state: " + state.toString());
            }
        }
    }
458238
void pin() {
		while (true) {
			int refCnt = pendingReferences.get();

			if (refCnt >= 0) {
				if (pendingReferences.compareAndSet(refCnt, refCnt + subpartitions.length)) {
					break;
				}
			}
			else {
				throw new IllegalStateException("Released.");
			}
		}
	}
266147
private void repin() {
		if (logger.isLoggable(Level.WARNING))
			logger.warning("Tx." + txNum + " is re-pinning all buffers");
		
		try {
			// Copy the set of pinned buffers to avoid ConcurrentModificationException
			List<BlockId> blksToBeRepinned = new LinkedList<BlockId>();
			Map<BlockId, Integer> pinCounts = new HashMap<BlockId, Integer>();
			List<Buffer> buffersToBeUnpinned = new LinkedList<Buffer>();
			
			// Record the buffers to be un-pinned and the blocks to be re-pinned
			for (Entry<BlockId, PinnedBuffer> entry : pinnedBuffers.entrySet()) {
				blksToBeRepinned.add(entry.getKey());
				pinCounts.put(entry.getKey(), entry.getValue().pinnedCount);
				buffersToBeUnpinned.add(entry.getValue().buffer);
			}
			
			// Un-pin all buffers it has
			for (Buffer buf : buffersToBeUnpinned)
				unpin(buf);

			// Wait other threads pinning blocks
			synchronized (bufferPool) {
				bufferPool.wait(MAX_TIME);
			}

			// Re-pin all blocks
			for (BlockId blk : blksToBeRepinned)
				pin(blk);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
165489
protected void unsetThreadContextProvider(ServiceReference<ThreadContextProvider> ref) {
        String threadContextProviderName = (String) ref.getProperty(COMPONENT_NAME);
        if (threadContextProviders.removeReference(threadContextProviderName, ref)
            && Boolean.TRUE.equals(ref.getProperty(ThreadContextProvider.ALWAYS_CAPTURE_THREAD_CONTEXT)))
            alwaysEnabled.remove(threadContextProviderName);
    }