// EnqueueMulticastQueueItem creates the given multicast queue-item.
558133
func (n *NetworkServerAPI) EnqueueMulticastQueueItem(ctx context.Context, req *ns.EnqueueMulticastQueueItemRequest) (*empty.Empty, error) {
	if req.MulticastQueueItem == nil {
		return nil, grpc.Errorf(codes.InvalidArgument, "multicast_queue_item must not be nil")
	}

	var mgID uuid.UUID
	copy(mgID[:], req.MulticastQueueItem.MulticastGroupId)

	qi := storage.MulticastQueueItem{
		MulticastGroupID: mgID,
		FCnt:             req.MulticastQueueItem.FCnt,
		FPort:            uint8(req.MulticastQueueItem.FPort),
		FRMPayload:       req.MulticastQueueItem.FrmPayload,
	}

	err := storage.Transaction(func(tx sqlx.Ext) error {
		return multicast.EnqueueQueueItem(storage.RedisPool(), tx, qi)
	})
	if err != nil {
		return nil, errToRPCError(err)
	}

	return &empty.Empty{}, nil
}
99648
func (t *taskQueue) enqueue(obj interface{}) {
	key, err := keyFunc(obj)
	if err != nil {
		glog.Infof("could not get key for object %+v: %v", obj, err)
		return
	}
	t.queue.Add(key)
}
89391
func HandleScheduleQueueItem(db sqlx.Ext, qi storage.MulticastQueueItem) error {
	ctx := multicastContext{
		DB:                 db,
		MulticastQueueItem: qi,
	}

	for _, t := range multicastTasks {
		if err := t(&ctx); err != nil {
			if err == errAbort {
				return nil
			}
			return err
		}
	}

	return nil
}
865173
func (b *Buffer) Enqueue(item interface{}) {
	b.rw.Lock()
	{
		b.buffer = append(b.buffer, item)
	}
	b.rw.Unlock()
}
831573
func (w *watchQueue) Enqueue(key string, kvp *kvdb.KVPair, err error) {
	w.m.Lock()
	w.updates.PushBack(&watchUpdate{key: key, kvp: kvp, err: err})
	w.cv.Signal()
	w.m.Unlock()
}
860054
func (q *Queue) Enqueue(cid cid.Cid) {
	select {
	case q.enqueue <- cid:
	case <-q.ctx.Done():
	}
}
208106
func GetDeviceQueueItemsForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) ([]DeviceQueueItem, error) {
	var items []DeviceQueueItem
	err := sqlx.Select(db, &items, `
        select
            *
        from
            device_queue
        where
            dev_eui = $1
        order by
            f_cnt`,
		devEUI,
	)
	if err != nil {
		return nil, handlePSQLError(err, "select error")
	}

	return items, nil
}
1168887
func (q *ListQueue) Dequeue() (interface{}, error) {
	if q.IsEmpty() {
		q.last = nil
		return nil, errors.New("unable to dequeue element, queue is empty")
	}

	item := q.first.item
	q.first = q.first.next
	q.size--
	return item, nil
}
993083
func (q *Queue) EnqueueString(value string) (*Item, error) {
	return q.Enqueue([]byte(value))
}
37184
func (n *NetworkServerAPI) GetMulticastQueueItemsForMulticastGroup(ctx context.Context, req *ns.GetMulticastQueueItemsForMulticastGroupRequest) (*ns.GetMulticastQueueItemsForMulticastGroupResponse, error) {
	var mgID uuid.UUID
	copy(mgID[:], req.MulticastGroupId)

	items, err := storage.GetMulticastQueueItemsForMulticastGroup(storage.DB(), mgID)
	if err != nil {
		return nil, errToRPCError(err)
	}

	counterSeen := make(map[uint32]struct{})
	var out ns.GetMulticastQueueItemsForMulticastGroupResponse
	for i := range items {
		// we need to de-duplicate the queue-items as they are created per-gateway
		if _, seen := counterSeen[items[i].FCnt]; seen {
			continue
		}

		qi := ns.MulticastQueueItem{
			MulticastGroupId: items[i].MulticastGroupID.Bytes(),
			FrmPayload:       items[i].FRMPayload,
			FCnt:             items[i].FCnt,
			FPort:            uint32(items[i].FPort),
		}
		counterSeen[items[i].FCnt] = struct{}{}
		out.MulticastQueueItems = append(out.MulticastQueueItems, &qi)
	}

	return &out, nil
}
828812
func (w *watchQueue) Enqueue(update *watchUpdate) {
	w.m.Lock()
	w.updates = append(w.updates, update)
	w.cv.Signal()
	w.m.Unlock()
}
355023
func FlushMulticastQueueForMulticastGroup(db sqlx.Execer, multicastGroupID uuid.UUID) error {
	_, err := db.Exec(`
		delete from
			multicast_queue
		where
			multicast_group_id = $1
	`, multicastGroupID)
	if err != nil {
		return handlePSQLError(err, "delete error")
	}

	log.WithFields(log.Fields{
		"multicast_group_id": multicastGroupID,
	}).Info("multicast-group queue flushed")

	return nil
}
141902
func (c *UnidlingController) enqueueEvent(event *corev1.Event) {
	if event.Reason != unidlingapi.NeedPodsReason {
		return
	}

	info := types.NamespacedName{
		Namespace: event.InvolvedObject.Namespace,
		Name:      event.InvolvedObject.Name,
	}

	// only add things to the queue if they're newer than what we already have
	if c.lastFiredCache.AddIfNewer(info, event.LastTimestamp.Time) {
		c.queue.Add(info)
	}
}
423818
func (s *UtxoScanner) Enqueue(input *InputWithScript,
	birthHeight uint32) (*GetUtxoRequest, error) {

	log.Debugf("Enqueuing request for %s with birth height %d",
		input.OutPoint.String(), birthHeight)

	req := &GetUtxoRequest{
		Input:       input,
		BirthHeight: birthHeight,
		resultChan:  make(chan *getUtxoResult, 1),
		quit:        s.quit,
	}

	s.cv.L.Lock()
	select {
	case <-s.quit:
		s.cv.L.Unlock()
		return nil, ErrShuttingDown
	default:
	}

	// Insert the request into the queue and signal any threads that might be
	// waiting for new elements.
	heap.Push(&s.pq, req)

	s.cv.L.Unlock()
	s.cv.Signal()

	return req, nil
}
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)
}
891632
func (c *RedisClient) Enqueue(jobIds ...string) error {

	args := redis.Args{}
	args.AddFlat(jobIds)
	_, err := c.conn.Do("ENQUEUE", args)
	return err
}
103632
func (tc *TransCache) HasItem(chID, itmID string) (has bool) {
	tc.cacheMux.RLock()
	has = tc.cacheInstance(chID).HasItem(itmID)
	tc.cacheMux.RUnlock()
	return
}