/*
Get the Queue for the respective id, if one is not available
create a new queue for that corresponding id and return it
971170
private WeightedQueue getWeightedQueue(String id)
    {
        WeightedQueue weightedQueue = queues.get(id);
        if (weightedQueue != null)
            // queue existed
            return weightedQueue;

        WeightedQueue maybenew = new WeightedQueue(id, getWeight(id));
        weightedQueue = queues.putIfAbsent(id, maybenew);
        if (weightedQueue == null)
        {
            // created new queue: register for monitoring
            maybenew.register();
            return maybenew;
        }

        // another thread created the queue
        return weightedQueue;
    }
882960
function getNextJob(){
  let job = null;

  while(!job && queue.size() > 0){
    let id = queue.pop().id;
    job = map[id];
  }

  return (!!job)?job:null;
}
501000
static public Thread getThread(final long id) {
        final Thread[] threads = getAllThreads();
        for (Thread thread : threads)
            if (thread.getId() == id)
                return thread;
        return null;
    }
784349
def queues(key=nil)
      return nil if @shutdown_mutex.locked?

      return @queues if key.nil?

      # First try to return the queue named 'key' if it's available.
      return @queues[key] if @queues[key]

      # If the queue wasn't available, create or get the mutex that will
      # wrap creation of the Queue.
      @queue_init_mutexes[key] ||= Mutex.new

      # Otherwise, check to see if another process is already loading
      # the queue named 'key'.
      if @queue_init_mutexes[key].locked?
        # return an empty/false result if we're waiting for the queue
        # to be loaded and we're not the first process to request the queue
        return nil
      else
        begin
          @queue_init_mutexes[key].lock
          # we've locked the mutex, but only go ahead if the queue hasn't
          # been loaded. There's a race condition otherwise, and we could
          # end up loading the queue multiple times.
          if @queues[key].nil?
            @queues[key] = PersistentQueue.new(@path, key)
            @stats[:current_bytes] += @queues[key].initial_bytes
          end
        rescue Object => exc
          puts "ZOMG There was an exception reading back the queue. That totally sucks."
          puts "The exception was: #{exc}. Backtrace: #{exc.backtrace.join("\n")}"
        ensure
          @queue_init_mutexes[key].unlock
        end
      end

      return @queues[key]
    end
128040
function(id, msg, result) {
        var q = queues[id], sc;
        if (q && q.onEnd) {
            sc = q.context || q;
            q.onEnd.call(sc, _returnData(q, msg, result));
        }
    }
557442
function(id, loaded) {
        var q = queues[id], msg, w, d, h, n, url, s,
            insertBefore;

        if (q.timer) {
            // q.timer.cancel();
            clearTimeout(q.timer);
        }

        if (q.aborted) {
            msg = "transaction " + id + " was aborted";
            _fail(id, msg);
            return;
        }

        if (loaded) {
            q.url.shift(); 
            if (q.varName) {
                q.varName.shift(); 
            }
        } else {
            // This is the first pass: make sure the url is an array
            q.url = (L.isString(q.url)) ? [q.url] : q.url;
            if (q.varName) {
                q.varName = (L.isString(q.varName)) ? [q.varName] : q.varName;
            }
        }

        w = q.win; 
        d = w.document; 
        h = d.getElementsByTagName("head")[0];

        if (q.url.length === 0) {
            _finish(id);
            return;
        } 

        url = q.url[0];

        // if the url is undefined, this is probably a trailing comma problem in IE
        if (!url) {
            q.url.shift(); 
            return _next(id);
        }


        if (q.timeout) {
            // q.timer = L.later(q.timeout, q, _timeout, id);
            q.timer = setTimeout(function() { 
                _timeout(id);
            }, q.timeout);
        }

        if (q.type === "script") {
            n = _scriptNode(url, w, q.attributes);
        } else {
            n = _linkNode(url, w, q.attributes);
        }

        // track this node's load progress
        _track(q.type, n, id, url, w, q.url.length);

        // add the node to the queue so we can return it to the user supplied callback
        q.nodes.push(n);

        // add it to the head or insert it before 'insertBefore'.  Work around IE
        // bug if there is a base tag.
        insertBefore = q.insertBefore || 
                       d.getElementsByTagName('base')[0];

        if (insertBefore) {
            s = _get(insertBefore, id);
            if (s) {
                s.parentNode.insertBefore(n, s);
            }
        } else {
            h.appendChild(n);
        }
        

        // FireFox does not support the onload event for link nodes, so there is
        // no way to make the css requests synchronous. This means that the css 
        // rules in multiple files could be applied out of order in this browser
        // if a later request returns before an earlier one.  Safari too.
        if ((ua.webkit || ua.gecko) && q.type === "css") {
            _next(id, url);
        }
    }
947174
public String getQueuedFlowIds() {
    final List<Integer> allIds = new ArrayList<>();
    getRunningFlowsIdsHelper(allIds, this.queuedFlows.getAllEntries());
    Collections.sort(allIds);
    return allIds.toString();
  }
946528
def get_internal_queue(self, thread_id):
        
        if thread_id.startswith('__frame__'):
            thread_id = thread_id[thread_id.rfind('|') + 1:]
        return self._cmd_queue[thread_id]
401656
public T    getQueue()
    {
        Preconditions.checkState(state.get() == State.STARTED, "Not started");

        List<String>    localPreferredQueues = Lists.newArrayList(preferredQueues);
        if ( localPreferredQueues.size() > 0 )
        {
            String      key = localPreferredQueues.get(random.nextInt(localPreferredQueues.size()));
            return queues.get(key);
        }

        List<String>    keys = Lists.newArrayList(queues.keySet());
        String          key = keys.get(random.nextInt(keys.size()));
        return queues.get(key);
    }
1352424
public Integer getPreviousIDSeq(final String id) {
        Validate.notNull(id, "ID cannot be null");
        final Integer count = this.idCounts.get(id);
        if (count == null) {
            throw new TemplateProcessingException(
                    "Cannot obtain previous ID count for ID \"" + id + "\"");
        }
        return Integer.valueOf(count.intValue() - 1);
    }
362801
function (queueId) {
                var id = queueId;
                if (queueId == null) {
                    id = this.DEFAULT_QUEUE_KEY;
                }
                var queue = this.queues[id];
                if (queue && queue.list.length > 0) {
                    var curAnimInfo = queue.list.shift();
                    for (var i = 1, l = queue.list.length; i < l; i++) {
                        var animInfo = queue.list[i];
                        delete this.animations[animInfo.animId];
                    }
                    this.skipAnimation(curAnimInfo.animId);
                    delete this.queues[id];
                    return true;
                }
                return false;
            }
818801
@Override
	public QueueDefinition getQueue(String queueName) {
		if (!StringUtils.hasText(queueName)) {
			return null;
		}
		for (QueueDefinition qd: m_queues) {
			if (qd.getName().equals(queueName)) {
				return qd;
			}
		}
		log.warn("failed to find queue: {}", queueName);
		return null;
	}
355494
function(id) {
        var q = queues[id], sc;
        if (q.onTimeout) {
            sc = q.context || q;
            q.onTimeout.call(sc, _returnData(q));
        }

        _end(id, 'timeout', 'timeout');
    }
62331
function getNextId() {
    var dataIds = Object.keys(idIndexData)

    dataIds.sort(function (a, b) {
      return b - a
    })

    if (dataIds && dataIds[0]) {
      var id = _.parseInt(dataIds[0]) + 1
      return id
    } else {
      return 1
    }
  }
986351
def get(self, sid):
        
        return QueueContext(self._version, account_sid=self._solution['account_sid'], sid=sid, )
1031118
public function setQueueId($id)
    {
        if ($id === null) {
            $this->queueId = null;
            return $this;
        }

        if (!is_string($id)) {
            throw new InvalidArgumentException(
                'Queue ID must be a string'
            );
        }

        $this->queueId = $id;

        return $this;
    }
1120000
function(id) {
        var q = queues[id];
        q.finished = true;

        if (q.aborted) {
            var msg = "transaction " + id + " was aborted";
            _fail(id, msg);
            return;
        }

        // execute success callback
        if (q.onSuccess) {
            var sc=q.scope || q.win;
            q.onSuccess.call(sc, _returnData(q));
        }
    }