Offers an item to the given queue. No check is performed that the queue
actually belongs to this conveyor.

@return whether the item was accepted by the queue
@throws ConcurrentConveyorException if the draining thread has already left
496974
public final boolean offer(Queue<E> queue, E item) throws ConcurrentConveyorException {
        if (queue.offer(item)) {
            return true;
        } else {
            checkDrainerGone();
            unparkDrainer();
            return false;
        }
    }
379263
@Override
    public boolean offer(final WaitStrategy.Offerable o) throws InterruptedException {
        while (!o.offer()) {
            LockSupport.parkNanos(1l);
        }
        return true;
    }
377444
@Override
    public boolean offer(final E e) {
        if (null == e) {
            throw new NullPointerException();
        }
        // use a cached view on consumer index (potentially updated in loop)
        final int mask = this.mask;
        // LoadLoad
        long producerLimit = lvProducerLimit();
        long pIndex;
        do {
            // LoadLoad
            pIndex = lvProducerIndex();
            if (pIndex >= producerLimit) {
                // LoadLoad
                final long cIndex = lvConsumerIndex();
                producerLimit = cIndex + mask + 1;
                if (pIndex >= producerLimit) {
                    // FULL :(
                    return false;
                } else {
                    // update producer limit to the next index that we must recheck the consumer index
                    // this is racy, but the race is benign
                    soProducerLimit(producerLimit);
                }
            }
        } while (!casProducerIndex(pIndex, pIndex + 1));
        /*
         * NOTE: the new producer index value is made visible BEFORE the element in the array. If we relied on
         * the index visibility to poll() we would need to handle the case where the element is not visible.
         */
        // Won CAS, move on to storing
        final int offset = calcElementOffset(pIndex, mask);
        // StoreStore
        soElement(buffer, offset, e);
        // AWESOME :)
        return true;
    }
1072835
public boolean offer(byte[] data) throws Exception
    {
        String thisPath = ZKPaths.makePath(path, PREFIX);
        client.create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(thisPath, data);
        return true;
    }
224553
public boolean doesMEHostQueuePoint(SIBUuid8 meUuid)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "doesMEHostQueuePoint", new Object[] { meUuid });

    boolean result = _queuePointsGuessSet.contains(meUuid);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "doesMEHostQueuePoint", Boolean.valueOf(result));
    return result;
  }
1227710
@Override
    public final boolean offer(T e, long timeout, TimeUnit unit) throws InterruptedException {
        final Queue<T> queue = this.getOrCreateQueue(e);

        final long start = getWriteLockWithOptionalWait(timeout, unit);
        if (start == Long.MIN_VALUE) {
            // Min value signals a timeout while waiting
            return false;
        }
        final long maxWait = start >= 0 ? unit.toMillis(timeout) : -1;

        try {
            if (!this.waitForRemove(start, maxWait)) {
                return false;
            }

            final boolean added = queue.add(e);
            if (added) {
                this.size++;
                this.notEmpty.signal();
            }
            return added;
        } finally {
            this.writeLock.unlock();
        }
    }
479751
@Override
    public T poll() {
        T old = null;

        boolean expedited = false;

        synchronized (this) {
            if (numberOfUsedExpeditedSlots.get() > 0) {
                old = expeditedExtract();
                numberOfUsedExpeditedSlots.getAndDecrement();
                expedited = true;
            } else if (numberOfUsedSlots.get() > 0) {
                old = extract();
                numberOfUsedSlots.getAndDecrement();
            }
        }

        if (old != null) {
            //TODO if expedited is added for put or offer with timeout add notification here
            if (!expedited)
                notifyPut_();
        }

        return old;
    }
187247
protected boolean putToQueue(IQueueMessage<ID, DATA> msg) {
        try {
            BytesMessage message = getProducerSession().createBytesMessage();
            message.writeBytes(serialize(msg));
            getMessageProducer().send(message);
            return true;
        } catch (Exception e) {
            throw e instanceof QueueException ? (QueueException) e : new QueueException(e);
        }
    }
271436
@Override
    public boolean offer(final WaitStrategy.Offerable o) throws InterruptedException {
        double currentBackoff = backoffNanos;
        while (!o.offer()) {
            LockSupport.parkNanos((long) currentBackoff);
            currentBackoff = currentBackoff * coefficient;

        }
        return true;
    }
590708
@SuppressWarnings("unchecked")
    @Override
    public E poll()
    {
        final E[] buffer = consumerBuffer;
        final long mask = consumerMask;

        final long index = lpConsumerIndex();
        final long offset = modifiedCalcElementOffset(index, mask);
        Object e = lvElement(buffer, offset);// LoadLoad
        if (e == null)
        {
            // consumer can't see the odd producer index
            if (index != lvProducerIndex())
            {
                // poll() == null iff queue is empty, null element is not strong enough indicator, so we must
                // check the producer index. If the queue is indeed not empty we spin until element is
                // visible.
                e = spinWaitForElement(buffer, offset);
            }
            else
            {
                return null;
            }
        }

        soElement(buffer, offset, null); // release element null
        soConsumerIndex(index + 2); // release cIndex
        return (E) e;
    }
1056554
public boolean offer(ObjectContainer<T> item)
  {
    final long itemLength = item.getSize();

    if (currentMemory.addAndGet(itemLength) <= memoryBound) {
      if (queue.offer(item)) {
        return true;
      }
    }
    currentMemory.addAndGet(-itemLength);
    return false;
  }
1342598
public boolean offer(T element) {
		if (size < capacity) {
			put(element);
			return true;
		} else if (size > 0 && !lessThan(element, peek())) {
			heap[1] = element;
			adjustTop();
			return true;
		} else {
			return false;
		}
	}
1096065
@Override
    public int drainTo(Collection<? super T> c, int maxElements) {

        //TODO- The elements aren't added to the given collection...

        if (c == null)
            throw new NullPointerException();
        if (c == this)
            throw new IllegalArgumentException();

        int n = Math.min(maxElements, size());

        int numRemaining = n;

        synchronized (this) {
            synchronized (lock) {
                //Retrieve and remove at most n elements from the expedited buffer and add them to the passed collection
                for (int i = 0; i < n; i++) {
                    T retrieved = expeditedExtract();
                    numRemaining = n - i;
                    if (retrieved != null) {
                        numberOfUsedExpeditedSlots.getAndDecrement();
                        //TODO if expedited is added for put or offer with timeout add notification here
                    } else {
                        break; //retrieved is null so nothing left in the expedited buffer, move on to the main buffer
                    }
                }
                //Retrieve and remove at most numRemaining elements and add them to the passed collection
                for (int i = 0; i < numRemaining; i++) {
                    T retrieved = extract();
                    numberOfUsedSlots.getAndDecrement();
                    if (retrieved != null) {
                        notifyPut_();
                    }
                }
            }
        }
        return n;
    }
1292016
def put_nowait(self, item: _T) -> None:
        
        self._consume_expired()
        if self._getters:
            assert self.empty(), "queue non-empty, why are getters waiting?"
            getter = self._getters.popleft()
            self.__put_internal(item)
            future_set_result_unless_cancelled(getter, self._get())
        elif self.full():
            raise QueueFull
        else:
            self.__put_internal(item)
475664
private void _fetch(BlockingQueue<ConsumerRecord<String, byte[]>> buffer, String topic,
            long waitTime, TimeUnit waitTimeUnit) {
        KafkaConsumer<String, byte[]> consumer = _getConsumer(topic);
        synchronized (consumer) {
            _checkAndSubscribe(consumer, topic);
            Set<String> subscription = consumer.subscription();
            ConsumerRecords<String, byte[]> crList = subscription != null
                    && subscription.contains(topic) ? consumer.poll(waitTimeUnit.toMillis(waitTime))
                            : null;
            if (crList != null) {
                for (ConsumerRecord<String, byte[]> cr : crList) {
                    buffer.offer(cr);
                }
            }
        }
    }
1324729
protected void putToQueue(IQueueMessage<ID, DATA> msg) throws QueueException.QueueIsFull {
        if (!queue.offer(msg)) {
            throw new QueueException.QueueIsFull(getBoundary());
        }
    }
798151
public final void drainerFailed(Throwable t) {
        if (t == null) {
            throw new NullPointerException("ConcurrentConveyor.drainerFailed(null)");
        }
        drainer = null;
        drainerDepartureCause = t;
    }