enqueue the attempt into our underlying queue. since it's expensive to dynamically
resize the queue, we have a separate rejection threshold which, if less than 0 is
ignored, but otherwise is the practical cap on the size of the queue.
481515
private boolean tryEnqueueAttempt(DelayedExecution<T> delayedExecution) {
    int rejectionThreshold = queueRejectionThreshold.get();
    if (rejectionThreshold < 0) {
      return requestQueue.offer(delayedExecution);
    }
    long stamp = stampedLock.readLock();
    try {
      while (requestQueue.size() < rejectionThreshold) {
        long writeStamp = stampedLock.tryConvertToWriteLock(stamp);
        if (writeStamp != 0L) {
          stamp = writeStamp;
          return requestQueue.offer(delayedExecution);
        } else {
          stampedLock.unlock(stamp);
          stamp = stampedLock.writeLock();
        }
      }
      return false;
    } finally {
      stampedLock.unlock(stamp);
    }
  }
915221
def _enqueue(self, msg: Any, rid: int, signer: Signer) -> None:
        
        if rid not in self.outBoxes:
            self.outBoxes[rid] = deque()
        self.outBoxes[rid].append(msg)
873183
public final void enqueue(Object obj)
  {
//    if (tc.isEntryEnabled())
//      SibTr.entry(tc, "enqueue", obj);
    // m_array has at least one position in it that is free.
    m_array[m_tail++] = obj;
    if (m_tail == m_array.length)
      m_tail = 0;
    if (m_head == m_tail)
      expand_array();
//    if (tc.isEntryEnabled())
//      SibTr.exit(tc, "enqueue");
  }
1037515
def add_attempt(self):
        
        self.attempt += 1
        self.attempt = min(self.attempt, self.max_check_attempts)
45341
def enqueue(self, payload, interval, job_id,
                queue_id, queue_type='default', requeue_limit=None):
        
        # validate all the input
        if not is_valid_interval(interval):
            raise BadArgumentException('`interval` has an invalid value.')

        if not is_valid_identifier(job_id):
            raise BadArgumentException('`job_id` has an invalid value.')

        if not is_valid_identifier(queue_id):
            raise BadArgumentException('`queue_id` has an invalid value.')

        if not is_valid_identifier(queue_type):
            raise BadArgumentException('`queue_type` has an invalid value.')

        if requeue_limit is None:
            requeue_limit = self._default_job_requeue_limit

        if not is_valid_requeue_limit(requeue_limit):
            raise BadArgumentException('`requeue_limit` has an invalid value.')

        try:
            serialized_payload = serialize_payload(payload)
        except TypeError as e:
            raise BadArgumentException(e.message)

        timestamp = str(generate_epoch())

        keys = [
            self._key_prefix,
            queue_type
        ]

        args = [
            timestamp,
            queue_id,
            job_id,
            '"%s"' % serialized_payload,
            interval,
            requeue_limit
        ]

        self._lua_enqueue(keys=keys, args=args)

        response = {
            'status': 'queued'
        }
        return response
878534
public void enQueue(QueueElement newElement)
    {
        QueueElement pCur = pHead, pPre = null;

        while (pCur != null && pCur.weight < newElement.weight)
        {
            pPre = pCur;
            pCur = pCur.next;
        }

        newElement.next = pCur;

        if (pPre == null)
            pHead = newElement;
        else
            pPre.next = newElement;
    }
798042
public static <E> E takeUninterruptibly(BlockingQueue<E> queue) {
    boolean interrupted = false;
    try {
      while (true) {
        try {
          return queue.take();
        } catch (InterruptedException e) {
          interrupted = true;
        }
      }
    } finally {
      if (interrupted) {
        Thread.currentThread().interrupt();
      }
    }
  }
347484
public AbstractQueue<ID, DATA> init() throws Exception {
        if (observer != null) {
            observer.preInit(this);
        }
        try {
            return this;
        } finally {
            if (observer != null) {
                observer.postInit(this);
            }
        }
    }
825519
function _queueTimeout(timeout) {
    // insert the new timeout at the right place in the array, sorted by time
    if (timeouts.length > 0) {
      var i = timeouts.length - 1;
      while (i >= 0 && timeouts[i].time > timeout.time) {
        i--;
      }

      // insert the new timeout in the queue. Note that the timeout is
      // inserted *after* existing timeouts with the exact *same* time,
      // so the order in which they are executed is deterministic
      timeouts.splice(i + 1, 0, timeout);
    }
    else {
      // queue is empty, append the new timeout
      timeouts.push(timeout);
    }
  }
746231
@Override
	public boolean offer(E e) {
		if (sizeLimit > 0 && size() >= sizeLimit){
			return false;
		}else{
			return queue.offer(e);
		}
	}
1207073
function processQueue(){
      try {
        // mark queue as processing to avoid concurrency
        processing = true;

        // process queue
        var item;
        while (item = queue.shift())
          item.fn.call(item.context);
      } finally {
        // queue is not processing anymore
        processing = false;

        // if any function in queue than exception was occured,
        // run rest functions in next code frame
        if (queue.length)
          timer = setImmediate(process);
      }
    }
79754
def re_enqueue(self, item):
        """"""
        if 'retries' in item:
            retries = item['retries']
            if retries >= self.MAX_RETRIES:
                log.warn("Failed to execute {} after {} retries, give it "
                         " up.".format(item['method'], retries))
            else:
                retries += 1
                item['retries'] = retries
                self._q.put_nowait(item)
        else:
            item['retries'] = 1
            self._q.put_nowait(item)
59692
protected void setupQueue() throws IOException {
		if (queueName != null) {
			channel.queueDeclare(queueName, false, false, false, null);
		}
	}
433009
def _flush_queue(self, q, ignore_priority=False):
        
        assert isinstance(q, PriorityQueue)

        current_timestamp = compute_release_time(lag_in_minutes=0)
        for _ in range(len(q)):
            entry = q.pop()
            assert isinstance(entry, PriorityEntry)

            if ignore_priority or entry.release_time < current_timestamp:
                self._resubmit_uow(entry.entry)
            else:
                q.put(entry)
                break
230065
private void tryCreateExternalQueue(int index) {
        AuxState aux;
        if ((aux = auxState) != null && index >= 0) {
            WorkQueue q = new WorkQueue(this, null);
            q.config = index;
            q.scanState = ~UNSIGNALLED;
            q.qlock = 1;                   // lock queue
            boolean installed = false;
            aux.lock();
            try {                          // lock pool to install
                WorkQueue[] ws;
                if ((ws = workQueues) != null && index < ws.length &&
                    ws[index] == null) {
                    ws[index] = q;         // else throw away
                    installed = true;
                }
            } finally {
                aux.unlock();
            }
            if (installed) {
                try {
                    q.growArray();
                } finally {
                    q.qlock = 0;
                }
            }
        }
    }
868359
function queueOrRequest( el ){
			var url = el.data( "url" );
			if( o.proxy && $.inArray( url, urllist ) === -1 ){
				urllist.push( url );
				elQueue = elQueue.add( el );
			}
			else{
				AI.makeReq( url, el );
			}
		}
410294
function runQueue(){
			if( urllist.length ){
				AI.makeReq( o.proxy + urllist.join( "," ), elQueue );
				elQueue = $();
				urllist = [];
			}
		}