// NewPQueue creates a new priority queue with the provided pqtype
// ordering type
510853
func NewPQueue(pqType PQType) *PQueue {
	var cmp func(int, int) bool

	if pqType == MAXPQ {
		cmp = max
	} else {
		cmp = min
	}

	items := make([]*item, 1)
	items[0] = nil // Heap queue first element should always be nil

	return &PQueue{
		items:      items,
		elemsCount: 0,
		comparator: cmp,
	}
}
1155990
func (b *AMQPCeleryBroker) CreateQueue() error {
	_, err := b.QueueDeclare(
		b.queue.Name,
		b.queue.Durable,
		b.queue.AutoDelete,
		false,
		false,
		nil,
	)
	return err
}
50376
func (pq *PriorityQueue) Peek() Item {
	pq.lock.Lock()
	defer pq.lock.Unlock()
	if len(pq.items) > 0 {
		return pq.items[0]
	}
	return nil
}
1041961
func newBlockEventQueue() *blockEventQueue {
	b := &blockEventQueue{
		newBlocks:   make(chan *FilteredBlock),
		staleBlocks: make(chan *FilteredBlock),
		quit:        make(chan struct{}),
	}
	b.queueCond = sync.NewCond(&b.queueMtx)

	return b
}
420679
func NewUniqueQueue(queueLength int) *UniqueQueue {
	if queueLength <= 0 {
		queueLength = 100
	}

	return &UniqueQueue{
		table: NewStatusTable(),
		queue: make(chan string, queueLength),
	}
}
586961
func NewConcurrentQueue(bufferSize int) *ConcurrentQueue {
	return &ConcurrentQueue{
		chanIn:   make(chan interface{}),
		chanOut:  make(chan interface{}, bufferSize),
		overflow: list.New(),
		quit:     make(chan struct{}),
	}
}
163065
func New(queueName string, sess *session.Session) (*SQS, error) {
	s := &SQS{
		session:  sess,
		queueURL: &queueName,
	}

	resp, err := s.client().GetQueueUrl(&sqs.GetQueueUrlInput{
		QueueName: aws.String(queueName),
	})
	if err != nil {
		return nil, err

	}

	s.queueURL = resp.QueueUrl
	return s, nil
}
1097540
func NewCtxQueue() *CtxQueue {
	return &CtxQueue{
		c:          make(chan ctxQueueMessage),
		o:          &sync.Once{},
		startC:     sync.NewCond(&sync.Mutex{}),
		statListen: astistat.NewDurationRatioStat(),
	}
}
144216
func (s *Job) SetQueue(v string) *Job {
	s.Queue = &v
	return s
}
285778
func NewFilterQueue(queueSeparation bool, MarkValue int, QueueStart, NumberOfNetworkQueues, NumberOfApplicationQueues uint16, NetworkQueueSize, ApplicationQueueSize uint32) *FilterQueue {

	fq := &FilterQueue{
		QueueSeparation:      queueSeparation,
		MarkValue:            MarkValue,
		NetworkQueueSize:     NetworkQueueSize,
		ApplicationQueueSize: ApplicationQueueSize,
	}

	if queueSeparation {

		fq.ApplicationQueue = QueueStart
		fq.ApplicationQueuesSynStr = strconv.Itoa(int(fq.ApplicationQueue)) + ":" + strconv.Itoa(int(fq.ApplicationQueue+NumberOfApplicationQueues-1))
		fq.ApplicationQueuesAckStr = strconv.Itoa(int(fq.ApplicationQueue+1*NumberOfApplicationQueues)) + ":" + strconv.Itoa(int(fq.ApplicationQueue+2*NumberOfApplicationQueues-1))
		fq.ApplicationQueuesSynAckStr = strconv.Itoa(int(fq.ApplicationQueue+2*NumberOfApplicationQueues)) + ":" + strconv.Itoa(int(fq.ApplicationQueue+3*NumberOfApplicationQueues-1))
		fq.ApplicationQueuesSvcStr = strconv.Itoa(int(fq.ApplicationQueue+3*NumberOfApplicationQueues)) + ":" + strconv.Itoa(int(fq.ApplicationQueue+4*NumberOfApplicationQueues-1))
		fq.NumberOfApplicationQueues = NumberOfApplicationQueues * 4

		fq.NetworkQueue = QueueStart + fq.NumberOfApplicationQueues
		fq.NetworkQueuesSynStr = strconv.Itoa(int(fq.NetworkQueue)) + ":" + strconv.Itoa(int(fq.NetworkQueue+NumberOfNetworkQueues-1))
		fq.NetworkQueuesAckStr = strconv.Itoa(int(fq.NetworkQueue+1*NumberOfNetworkQueues)) + ":" + strconv.Itoa(int(fq.NetworkQueue+2*NumberOfNetworkQueues-1))
		fq.NetworkQueuesSynAckStr = strconv.Itoa(int(fq.NetworkQueue+2*NumberOfNetworkQueues)) + ":" + strconv.Itoa(int(fq.NetworkQueue+3*NumberOfNetworkQueues-1))
		fq.NetworkQueuesSvcStr = strconv.Itoa(int(fq.NetworkQueue+3*NumberOfNetworkQueues)) + ":" + strconv.Itoa(int(fq.NetworkQueue+4*NumberOfNetworkQueues-1))
		fq.NumberOfNetworkQueues = NumberOfNetworkQueues * 4
	} else {

		fq.ApplicationQueue = QueueStart
		fq.ApplicationQueuesSynStr = strconv.Itoa(int(fq.ApplicationQueue)) + ":" + strconv.Itoa(int(fq.ApplicationQueue+NumberOfApplicationQueues-1))
		fq.ApplicationQueuesAckStr = fq.ApplicationQueuesSynStr
		fq.ApplicationQueuesSvcStr = fq.ApplicationQueuesSynStr
		fq.ApplicationQueuesSynAckStr = fq.ApplicationQueuesSynStr
		fq.NumberOfApplicationQueues = NumberOfApplicationQueues

		fq.NetworkQueue = QueueStart + fq.NumberOfApplicationQueues
		fq.NetworkQueuesSynStr = strconv.Itoa(int(fq.NetworkQueue)) + ":" + strconv.Itoa(int(fq.NetworkQueue+NumberOfNetworkQueues-1))
		fq.NetworkQueuesAckStr = fq.NetworkQueuesSynStr
		fq.NetworkQueuesSynAckStr = fq.NetworkQueuesSynStr
		fq.NetworkQueuesSvcStr = fq.NetworkQueuesSynStr
		fq.NumberOfNetworkQueues = NumberOfNetworkQueues
	}

	return fq
}
860054
func (q *Queue) Enqueue(cid cid.Cid) {
	select {
	case q.enqueue <- cid:
	case <-q.ctx.Done():
	}
}
606040
func NewQueue() (q *Queue) {
	initChunk := new(chunk)
	q = &Queue{
		head: initChunk,
		tail: initChunk,
	}
	return q
}
462889
func NewEnqueueOpts(config *config.Config) *EnqueueOpts {
	return &EnqueueOpts{
		RetryEnabled:      config.GetBool("pitaya.worker.retry.enabled"),
		MaxRetries:        config.GetInt("pitaya.worker.retry.max"),
		ExponentialFactor: config.GetInt("pitaya.worker.retry.exponential"),
		MinDelayToRetry:   config.GetInt("pitaya.worker.retry.minDelay"),
		MaxDelayToRetry:   config.GetInt("pitaya.worker.retry.maxDelay"),
		MaxRandom:         config.GetInt("pitaya.worker.retry.maxRandom"),
	}
}
1346730
func NewRateLimitedTimedQueue(limiter flowcontrol.RateLimiter) *RateLimitedTimedQueue {
	return &RateLimitedTimedQueue{
		queue: UniqueQueue{
			queue: TimedQueue{},
			set:   sets.NewString(),
		},
		limiter: limiter,
	}
}
498168
func (b *PQueue) Enqueue(priority int, message *Message) error {
	k := make([]byte, 8)
	binary.BigEndian.PutUint64(k, aKey.Get())
	return b.enqueueMessage(priority, k, message)
}
296730
func (pq *PriorityQueue) UpdateObject(priority uint8, id uint64, newValue interface{}) (*PriorityItem, error) {
	var buffer bytes.Buffer
	enc := gob.NewEncoder(&buffer)
	if err := enc.Encode(newValue); err != nil {
		return nil, err
	}
	return pq.Update(priority, id, buffer.Bytes())
}
474802
func NewDroppingQueue(max int) Queue {
	return Queue{queue: make([]interface{}, 0, max), maxLen: max, mode: modeDrop}
}