Acquires a managed buffer from the pool. If the pool is empty,
waits for a buffer to become available. The acquired buffer has
a lock count of one.

@return the acquired buffer
@throws InterruptedException if the current thread is interrupted
195428
@SuppressWarnings("PMD.GuardLogStatement")
    public W acquire() throws InterruptedException {
        // Stop draining, because we obviously need this kind of buffers
        Optional.ofNullable(idleTimer.getAndSet(null)).ifPresent(
            timer -> timer.cancel());
        if (createdBufs.get() < maximumBufs) {
            // Haven't reached maximum, so if no buffer is queued, create one.
            W buffer = queue.poll();
            if (buffer != null) {
                buffer.lockBuffer();
                return buffer;
            }
            return createBuffer();
        }
        // Wait for buffer to become available.
        if (logger.isLoggable(Level.FINE)) {
            // If configured, log message after waiting some time.
            W buffer = queue.poll(acquireWarningLimit, TimeUnit.MILLISECONDS);
            if (buffer != null) {
                buffer.lockBuffer();
                return buffer;
            }
            logger.log(Level.FINE, new Throwable(),
                () -> Thread.currentThread().getName() + " waiting > "
                    + acquireWarningLimit + "ms for buffer, while executing:");
        }
        W buffer = queue.take();
        buffer.lockBuffer();
        return buffer;
    }
193685
public synchronized T borrow() throws JMSException
	{
		if (closed)
			throw new ObjectPoolException("Object pool is closed");
		
		// Object immediately available ?
		int availableCount = available.size();
		if (availableCount > 0)
			return available.remove(availableCount-1);
		
		// Can we create one more ?
		if (all.size() < maxSize)
			return extendPool();
		
		// Pool is exhausted
		switch (exhaustionPolicy)
		{
			case WHEN_EXHAUSTED_FAIL  : throw new ObjectPoolException("Pool is exhausted (maxSize="+maxSize+")");
			case WHEN_EXHAUSTED_BLOCK : return waitForAvailability();
			case WHEN_EXHAUSTED_WAIT  : return waitForAvailability(waitTimeout,true);
			case WHEN_EXHAUSTED_RETURN_NULL : return null;
			case WHEN_EXHAUSTED_WAIT_RETURN_NULL : return waitForAvailability(waitTimeout,false);
			
			default:
				throw new ObjectPoolException("Invalid exhaustion policy : "+exhaustionPolicy);
		}
	}
157203
private void waitGet_(long timeout) throws InterruptedException {

        // wait on a member of the lock array
        int lockIndex = getQueueIndex(getQueueLocks_, getQueueCounter_, true);
        synchronized (getQueueLocks_[lockIndex]) {
            try {

                // increment waiting threads
                getQueueLocks_[lockIndex].threadsWaiting++;

                // D497382 - Now that we have the getQueue_ lock, recheck the
                // condition from take/poll to try to minimize the number of
                // threads that wait but don't get notified.
                if (numberOfUsedSlots.get() <= 0) {

                    // determine timeout if unspecified
                    if (timeout < 0) {
                        if (WAIT_SHORT_SLICE_ != WAIT_LONG_SLICE_ && getQueueLocks_[lockIndex].shortWaiter == null) {

                            // use default timeout if not specified
                            timeout = WAIT_SHORT_SLICE_;

                            // there are no threads on waiting with short timeout,
                            // so this thread will use timeout value and set flag.
                            getQueueLocks_[lockIndex].shortWaiter = Thread.currentThread();
                        } else {

                            // there is already a thread on this queue waiting with
                            // short timeout set, so all other threads will wait a
                            // longer time to avoid contention of threads looking for
                            // work without being notified.
                            timeout = WAIT_LONG_SLICE_;
                        }
                    }

                    // notification through notifyGet_ may be lost here
                    getQueueLocks_[lockIndex].wait(timeout);
                }
            } catch (InterruptedException ex) {
                getQueueLocks_[lockIndex].notify();
                throw ex;
            } finally {

                // decrement waiting threads
                getQueueLocks_[lockIndex].threadsWaiting--;

                // check whether the current thread was waiting with a timeout.
                // if so, need to clear the flag to indicate that no thread is
                // waiting with timeout on this queue.
                if (WAIT_SHORT_SLICE_ != WAIT_LONG_SLICE_)
                    if (getQueueLocks_[lockIndex].shortWaiter == Thread.currentThread())
                        getQueueLocks_[lockIndex].shortWaiter = null;
            }
        }
    }
957194
@Override
    public T get() throws InterruptedException {
        try {
            get(0, null);
        } catch (TimeoutException e) {
            e.printStackTrace();
        }
        return t;
    }
1357962
public synchronized Object get() {
        Object o = null;

        while ((o = tryGet()) == null) {
            try {
                this.wait();
            } catch (final InterruptedException e) {
            }
        }
        return o;
    }
640430
public CloseableResource<BlockMasterClient> acquireBlockMasterClientResource() {
    return new CloseableResource<BlockMasterClient>(mBlockMasterClientPool.acquire()) {
      @Override
      public void close() {
        mBlockMasterClientPool.release(get());
      }
    };
  }
689399
public ByteBuffer fetch(long position) throws InterruptedException, ExecutionException {
    long blockIndex = position / bufSize;
    boolean goingBack = false;
    for (WorkUnit w : full) {
      if (w.blockIndex == blockIndex) {
        ensureFetching(blockIndex + 1);
        nbHit++;
        return w.buf;
      } else if (w.blockIndex > blockIndex) {
        goingBack = true;
      }
    }
    if (goingBack) {
      // user is asking for a block with a lower index than we've already fetched -
      // in other words they are not following the expected pattern of increasing indexes.
      nbGoingBack++;
    }
    if (null == fetching) {
      ensureFetching(blockIndex);
    }
    WorkUnit candidate = fetching;
    // block until we have the buffer
    ByteBuffer buf = candidate.getBuf();
    full.add(candidate);
    fetching = null;
    if (candidate.blockIndex == blockIndex) {
      // this is who we were waiting for
      nbNearHit++;
      ensureFetching(blockIndex + 1);
      return buf;
    } else {
      // wrong block. Let's fetch the right one now.
      nbMiss++;
      ensureFetching(blockIndex);
      candidate = fetching;
      buf = candidate.getBuf();
      full.add(candidate);
      fetching = null;
      ensureFetching(blockIndex + 1);
      return buf;
    }
  }
629969
async def acquire(self, command=None, args=()):
        
        if self.closed:
            raise PoolClosedError("Pool is closed")
        async with self._cond:
            if self.closed:
                raise PoolClosedError("Pool is closed")
            while True:
                await self._fill_free(override_min=True)
                if self.freesize:
                    conn = self._pool.popleft()
                    assert not conn.closed, conn
                    assert conn not in self._used, (conn, self._used)
                    self._used.add(conn)
                    return conn
                else:
                    await self._cond.wait()
1254837
@Override
    public T take() throws InterruptedException {
        T old = poll();

        while (old == null) {
            waitGet_(-1);
            old = poll();
        }

        return old;
    }
695785
public Long waitForProcess() throws InterruptedException {
        Long processId = waitProcessIds.peek();
        if (logger.isDebugEnabled()) {
            logger.debug("## {} get termin id [{}]", getPipelineId(), processId);
        }
        return processId;
    }
1005058
@Override
    public E peek() {
        // Copy field to avoid re-reading after volatile load
        final AtomicReferenceArray<E> buffer = this.buffer;

        final long consumerIndex = lvConsumerIndex(); // LoadLoad
        final int offset = calcElementOffset(consumerIndex);
        E e = lvElement(buffer, offset);
        if (null == e) {
            /*
             * NOTE: Queue may not actually be empty in the case of a producer (P1) being interrupted after
             * winning the CAS on offer but before storing the element in the queue. Other producers may go on
             * to fill up the queue after this element.
             */
            if (consumerIndex != lvProducerIndex()) {
                do {
                    e = lvElement(buffer, offset);
                } while (e == null);
            } else {
                return null;
            }
        }
        return e;
    }
158234
public JobStatus.State reload() throws InterruptedException {
    // [START ]
    while (!JobStatus.State.DONE.equals(job.getStatus().getState())) {
      Thread.sleep(1000L);
      job = job.reload();
    }
    // [END ]
    return job.getStatus().getState();
  }
628206
@Override
    public T take(final com.oath.cyclops.async.wait.WaitStrategy.Takeable<T> t) throws InterruptedException {
        T result;

        while ((result = t.take()) == null) {

        }

        return result;
    }
418169
private Worker getWorker() throws InterruptedException {
    while (!courtesyMonitor.allowTasksToRun()) {
      courtesyMonitor.waitFor();
    }
    while (numWorkers > maxWorkers) {
      workerQueue.take();
      numWorkers--;
    }
    return workerQueue.take();
  }
918048
public ResourceHolder<ByteBuffer> getMergeBuffer()
  {
    final ByteBuffer buffer = mergeBuffers.pop();
    return new ResourceHolder<ByteBuffer>()
    {
      @Override
      public ByteBuffer get()
      {
        return buffer;
      }

      @Override
      public void close()
      {
        mergeBuffers.add(buffer);
      }
    };
  }
816391
@Override
    public V get() throws InterruptedException, ExecutionException {
        this.m_coordinationLatch.await();

        if (m_pendingException != null) {
            throw m_pendingException;
        }

        return m_defaultFuture.get();
    }
102480
public CompilerThread grabCompilerThread() throws InterruptedException {
        available.acquire();
        if (compilers.empty()) {
            return new CompilerThread(this);
        }
        return compilers.pop();
    }