base/common/src/main/com/thesett/common/util/concurrent/BatchSynchQueueBase.java
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
    {
        if (e == null)
        {
            throw new IllegalArgumentException("The 'e' parameter may not be null.");
        }

        ReentrantLock lock = this.lock;
        lock.lockInterruptibly();

        long nanos = unit.toNanos(timeout);

        try
        {
            do
            {
                if (insert(e, false))
                {
                    return true;
                }

                try
                {
                    nanos = notFull.awaitNanos(nanos);
                }
                catch (InterruptedException ie)
                {
                    // Wake up another thread waiting on notFull, as the condition may be true, but this thread
                    // was interrupted so cannot make use of it.
                    notFull.signal();

                    throw ie;
                }
            }
            while (nanos > 0);

            return false;
        }
        finally
        {
            lock.unlock();
        }
    }
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
    {
        if (e == null)
        {
            throw new IllegalArgumentException("The 'e' parameter may not be null.");
        }

        ReentrantLock lock = this.lock;
        lock.lockInterruptibly();

        long nanos = unit.toNanos(timeout);

        try
        {
            do
            {
                if (insert(e, false))
                {
                    return true;
                }

                try
                {
                    nanos = notFull.awaitNanos(nanos);
                }
                catch (InterruptedException ie)
                {
                    // Wake up another thread waiting on notFull, as the condition may be true, but this thread
                    // was interrupted so cannot make use of it.
                    notFull.signal();

                    throw ie;
                }
            }
            while (nanos > 0);

            return false;
        }
        finally
        {
            lock.unlock();
        }
    }
public boolean offer ( E e , long timeout , TimeUnit unit ) throws InterruptedException { if ( e == null ) { throw new IllegalArgumentException ( "The 'e' parameter may not be null." ) ; } ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; long nanos = unit . toNanos ( timeout ) ; try { do { if ( insert ( e , false ) ) { return true ; } try { nanos = notFull . awaitNanos ( nanos ) ; } catch ( InterruptedException ie ) { // Wake up another thread waiting on notFull, as the condition may be true, but this thread // was interrupted so cannot make use of it. notFull . signal ( ) ; throw ie ; } } while ( nanos > 0 ) ; return false ; } finally { lock . unlock ( ) ; } }
Inserts the specified element into this queue, waiting if necessary up to the specified wait time for space to
become available.

@param  e       The element to add, may not be null.
@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 <tt>true</tt> if successful, or <tt>false</tt> if the specified waiting time elapses before space is
available.

@throws InterruptedException     If interrupted while waiting.
@throws IllegalArgumentException If the specified element is <tt>null</tt>.
Inserts the specified element into this queue waiting if necessary up to the specified wait time for space to become available .