base/common/src/main/com/thesett/common/util/concurrent/BatchSynchQueueBase.java
protected boolean insert(E element, boolean unlockAndBlock)
    {
        // Create a new record for the data item.
        SynchRecordImpl<E> record = new SynchRecordImpl<E>(element);

        boolean result = buffer.offer(record);

        if (result)
        {
            count++;

            // Tell any waiting consumers that the queue is not empty.
            notEmpty.signal();

            if (unlockAndBlock)
            {
                // Allow other threads to read/write the queue.
                lock.unlock();

                // Wait until a consumer takes this data item.
                record.waitForConsumer();
            }

            return true;
        }
        else
        {
            return false;
        }
    }
protected boolean insert(E element, boolean unlockAndBlock)
    {
        // Create a new record for the data item.
        SynchRecordImpl<E> record = new SynchRecordImpl<E>(element);

        boolean result = buffer.offer(record);

        if (result)
        {
            count++;

            // Tell any waiting consumers that the queue is not empty.
            notEmpty.signal();

            if (unlockAndBlock)
            {
                // Allow other threads to read/write the queue.
                lock.unlock();

                // Wait until a consumer takes this data item.
                record.waitForConsumer();
            }

            return true;
        }
        else
        {
            return false;
        }
    }
Insert element into the queue, then possibly signal that the queue is not empty and block the producer on the
element until permission to procede is given.

<p/>If the producer is to be blocked then the lock must be released first, otherwise no other process will be
able to get access to the queue. Hence, unlock and block are always set together.

<p/>Call only when holding the global lock.

@param  element        The element to insert in the queue.
@param  unlockAndBlock <tt>true</tt>If the global queue lock should be released and the producer should be
blocked.

@return <tt>true</tt> if the operation succeeded, <tt>false</tt> otherwise. If the result is <tt>true</tt> this
method may not return straight away, but only after the producer is unblocked by having its data consumed
if the unlockAndBlock flag is set. In the false case the method will return straight away, no matter what
value the unlockAndBlock flag has, leaving the global lock on.