base/common/src/main/com/thesett/common/util/queues/WrapperQueue.java
public E pollAccept(Object owner)
    {
        if (transactional)
        {
            E element = null;
            RequeueElementWrapper<E> record = null;

            // Find an element on the requeue that is free, or has already been acquired by the owner but not accepted.
            // Mark the element as acquired by the owner as necessary.
            if (!requeue.isEmpty())
            {
                for (RequeueElementWrapper<E> nextRecord : requeue)
                {
                    if (AcquireState.Free.equals(nextRecord.state))
                    {
                        record = nextRecord;
                        record.state = AcquireState.Acquired;
                        record.owner = owner;

                        element = record.element;

                        break;
                    }
                    else if (AcquireState.Acquired.equals(nextRecord.state) && owner.equals(nextRecord.owner))
                    {
                        record = nextRecord;
                        element = record.element;

                        break;
                    }
                }
            }

            // If an element cannot be found on the requeue, poll an element from the main queue, and place it onto the
            // requeue.
            if (record == null)
            {
                element = queue.poll();
            }

            // If no element at all can be found return null.
            if (element == null)
            {
                return element;
            }

            // Check that an element was actually available on the queue before creating a new acquired record for it
            // on the requeue.
            if (record == null)
            {
                record = requeue(element, owner, AcquireState.Acquired);
            }

            // Accept the element and create a transaction operation to remove it upon commit or unnaccept it upon
            // rollback.
            record.state = AcquireState.Accepted;
            txMethod.requestWriteOperation(new AcceptRecord(record));

            return record.element;
        }
        else
        {
            E element;

            // Find an element on the requeue that is free. Remove it and return it.
            if (!requeue.isEmpty())
            {
                for (RequeueElementWrapper<E> nextRecord : requeue)
                {
                    if (AcquireState.Free.equals(nextRecord.state))
                    {
                        requeue.remove(nextRecord);
                        requeuedElementMap.remove(nextRecord.element);

                        return nextRecord.element;
                    }
                }
            }

            // Or poll an element from the main queue and return it.
            element = queue.poll();

            if (element != null)
            {
                decrementSizeAndCount(element);
            }

            return element;
        }
    }
public E pollAccept(Object owner)
    {
        if (transactional)
        {
            E element = null;
            RequeueElementWrapper<E> record = null;

            // Find an element on the requeue that is free, or has already been acquired by the owner but not accepted.
            // Mark the element as acquired by the owner as necessary.
            if (!requeue.isEmpty())
            {
                for (RequeueElementWrapper<E> nextRecord : requeue)
                {
                    if (AcquireState.Free.equals(nextRecord.state))
                    {
                        record = nextRecord;
                        record.state = AcquireState.Acquired;
                        record.owner = owner;

                        element = record.element;

                        break;
                    }
                    else if (AcquireState.Acquired.equals(nextRecord.state) && owner.equals(nextRecord.owner))
                    {
                        record = nextRecord;
                        element = record.element;

                        break;
                    }
                }
            }

            // If an element cannot be found on the requeue, poll an element from the main queue, and place it onto the
            // requeue.
            if (record == null)
            {
                element = queue.poll();
            }

            // If no element at all can be found return null.
            if (element == null)
            {
                return element;
            }

            // Check that an element was actually available on the queue before creating a new acquired record for it
            // on the requeue.
            if (record == null)
            {
                record = requeue(element, owner, AcquireState.Acquired);
            }

            // Accept the element and create a transaction operation to remove it upon commit or unnaccept it upon
            // rollback.
            record.state = AcquireState.Accepted;
            txMethod.requestWriteOperation(new AcceptRecord(record));

            return record.element;
        }
        else
        {
            E element;

            // Find an element on the requeue that is free. Remove it and return it.
            if (!requeue.isEmpty())
            {
                for (RequeueElementWrapper<E> nextRecord : requeue)
                {
                    if (AcquireState.Free.equals(nextRecord.state))
                    {
                        requeue.remove(nextRecord);
                        requeuedElementMap.remove(nextRecord.element);

                        return nextRecord.element;
                    }
                }
            }

            // Or poll an element from the main queue and return it.
            element = queue.poll();

            if (element != null)
            {
                decrementSizeAndCount(element);
            }

            return element;
        }
    }
public E pollAccept ( Object owner ) { if ( transactional ) { E element = null ; RequeueElementWrapper < E > record = null ; // Find an element on the requeue that is free, or has already been acquired by the owner but not accepted. // Mark the element as acquired by the owner as necessary. if ( ! requeue . isEmpty ( ) ) { for ( RequeueElementWrapper < E > nextRecord : requeue ) { if ( AcquireState . Free . equals ( nextRecord . state ) ) { record = nextRecord ; record . state = AcquireState . Acquired ; record . owner = owner ; element = record . element ; break ; } else if ( AcquireState . Acquired . equals ( nextRecord . state ) && owner . equals ( nextRecord . owner ) ) { record = nextRecord ; element = record . element ; break ; } } } // If an element cannot be found on the requeue, poll an element from the main queue, and place it onto the // requeue. if ( record == null ) { element = queue . poll ( ) ; } // If no element at all can be found return null. if ( element == null ) { return element ; } // Check that an element was actually available on the queue before creating a new acquired record for it // on the requeue. if ( record == null ) { record = requeue ( element , owner , AcquireState . Acquired ) ; } // Accept the element and create a transaction operation to remove it upon commit or unnaccept it upon // rollback. record . state = AcquireState . Accepted ; txMethod . requestWriteOperation ( new AcceptRecord ( record ) ) ; return record . element ; } else { E element ; // Find an element on the requeue that is free. Remove it and return it. if ( ! requeue . isEmpty ( ) ) { for ( RequeueElementWrapper < E > nextRecord : requeue ) { if ( AcquireState . Free . equals ( nextRecord . state ) ) { requeue . remove ( nextRecord ) ; requeuedElementMap . remove ( nextRecord . element ) ; return nextRecord . element ; } } } // Or poll an element from the main queue and return it. element = queue . poll ( ) ; if ( element != null ) { decrementSizeAndCount ( element ) ; } return element ; } }
{@inheritDoc}
{