base/common/src/main/com/thesett/common/util/concurrent/BatchSynchQueueBase.java
public E poll(long timeout, TimeUnit unit) throws InterruptedException
    {
        ReentrantLock lock = this.lock;
        lock.lockInterruptibly();

        try
        {
            long nanos = unit.toNanos(timeout);

            do
            {
                if (count != 0)
                {
                    return extract(true, true).getElement();
                }

                try
                {
                    nanos = notEmpty.awaitNanos(nanos);
                }
                catch (InterruptedException ie)
                {
                    notEmpty.signal(); // propagate to non-interrupted thread
                    throw ie;
                }
            }
            while (nanos > 0);

            return null;
        }
        finally
        {
            lock.unlock();
        }
    }
public E poll(long timeout, TimeUnit unit) throws InterruptedException
    {
        ReentrantLock lock = this.lock;
        lock.lockInterruptibly();

        try
        {
            long nanos = unit.toNanos(timeout);

            do
            {
                if (count != 0)
                {
                    return extract(true, true).getElement();
                }

                try
                {
                    nanos = notEmpty.awaitNanos(nanos);
                }
                catch (InterruptedException ie)
                {
                    notEmpty.signal(); // propagate to non-interrupted thread
                    throw ie;
                }
            }
            while (nanos > 0);

            return null;
        }
        finally
        {
            lock.unlock();
        }
    }
public E poll ( long timeout , TimeUnit unit ) throws InterruptedException { ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; try { long nanos = unit . toNanos ( timeout ) ; do { if ( count != 0 ) { return extract ( true , true ) . getElement ( ) ; } try { nanos = notEmpty . awaitNanos ( nanos ) ; } catch ( InterruptedException ie ) { notEmpty . signal ( ) ; // propagate to non-interrupted thread throw ie ; } } while ( nanos > 0 ) ; return null ; } finally { lock . unlock ( ) ; } }
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time if no elements
are present on this queue.

@param  timeout How long to wait before giving up, in units of <tt>unit</tt>.
@param  unit    A <tt>TimeUnit</tt> determining how to interpret the <tt>timeout</tt> parameter.

@return The head of this queue, or <tt>null</tt> if the specified waiting time elapses before an element is
present.

@throws InterruptedException If interrupted while waiting.
Retrieves and removes the head of this queue waiting if necessary up to the specified wait time if no elements are present on this queue .