// add adds a new event and discards old events if possible
196794
func (l *logger) add(now mclock.AbsTime, event string) {
	keepAfter := now - mclock.AbsTime(l.keep)
	for l.delPtr < l.writePtr && l.events[l.delPtr].time <= keepAfter {
		delete(l.events, l.delPtr)
		l.delPtr++
	}
	l.events[l.writePtr] = logEvent{now, event}
	l.writePtr++
}
586498
func (f *ListenerStack) Add(fx ElemEventMux) int {
	var ind int

	f.lock.RLock()
	ind = len(f.listeners)
	f.lock.RUnlock()

	f.lock.Lock()
	f.listeners = append(f.listeners, fx)
	f.lock.Unlock()

	return ind
}
1268976
func (b *BarJSONBuilder) Add(info *BarPropertyInfo) *BarJSONBuilder {
	b._properties[info.fieldName] = info
	return b
}
1143544
func (h *History) Add(input string) {
	h.histories = append(h.histories, input)
	h.Clear()
}
189142
func (d *eventDispatcher) AddEventListener(typ string, listener EventListener) {
	d.Lock()
	defer d.Unlock()
	d.listeners[typ] = append(d.listeners[typ], listener)
}
606837
func (c *baseCatcher) Add(err error) {
	if err == nil {
		return
	}

	c.mutex.Lock()
	defer c.mutex.Unlock()

	c.errs = append(c.errs, err)
}
1316028
func (stats *Stats) Add(d time.Duration) {
	stats.durations = append(stats.durations, d)
	stats.dirty = true
}
1243318
func (self *events) AddEvent(e *Event) error {
	self.updateEventStore(e)
	self.watcherLock.RLock()
	defer self.watcherLock.RUnlock()
	watchesToSend := self.findValidWatchers(e)
	for _, watchObject := range watchesToSend {
		watchObject.eventChannel.GetChannel() <- e
	}
	log.Infof("WRIT %s %s", e.EventType, e.EventAction.String())
	return nil
}
1148771
func (err *MultiError) Add(errOrNil error) {
	if err != nil && errOrNil != nil {
		*err = append(*err, errOrNil)
	}
}
750714
func (r *RecordList) Add(ev EventBuilder, fn Listener) int {
	idx, rec := r.Find(ev.Name())
	if idx == -1 {
		rec := &record{ev: ev, name: ev.Name()}
		rec.setList([]unsafe.Pointer{unsafe.Pointer(&fn)})
		r.append(rec)
		return 1
	}

	oldList := rec.getUnsafeList()
	newCount := len(oldList) - rec.inactiveItems + 1
	if rec.inactiveItems == 0 {
		rec.inactiveItems = len(oldList)
		newList := make([]unsafe.Pointer, len(oldList)*2+1)
		// copy so that the new list items are at the end of the list,
		// this lets the slot search later run and find free space faster.
		copy(newList[len(oldList)+1:], oldList)
		newList[len(oldList)] = unsafe.Pointer(&fn)
		rec.setList(newList)
		return newCount
	}

	for i, ptr := range oldList {
		if ptr == nil {
			rec.storeAtIndex(i, fn)
			rec.inactiveItems--
			return newCount
		}
	}

	panic("unreachable")
}
601981
func (l *TimeLimiter) add(now time.Time, d time.Duration) {
	if now.After(l.next) {
		l.timeSpent = d
		l.since = now.Add(-d)
		l.next = l.since.Add(l.window)
		return
	}
	l.timeSpent += d
}
633882
func (c *Client) AddEvent(e contract.Event) (id string, err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	if e.ID != "" {
		_, err = uuid.Parse(e.ID)
		if err != nil {
			return "", db.ErrInvalidObjectId
		}
	}
	return addEvent(conn, e)
}
172620
func (c *Client) Add(data interface{}) error {
	c.ensureTransmission()
	c.ensureBuilder()
	return c.builder.Add(data)
}
674306
func (f *ItemFlagger) AddEvents(ctx context.Context, events []*event.Event, next Sink) error {
	if f.CtxFlagCheck.HasFlag(ctx) {
		atomic.AddInt64(&f.stats.totalEvCtxSignals, 1)
		for _, dp := range events {
			f.SetEventFlag(dp)
		}
		return next.AddEvents(ctx, events)
	}
	dims := f.GetDimensions()
	if len(dims) == 0 {
		return next.AddEvents(ctx, events)
	}
	for _, ev := range events {
		if evMatches(ev, dims) {
			atomic.AddInt64(&f.stats.totalEvDimSignals, 1)
			f.SetEventFlag(ev)
		}
	}
	return next.AddEvents(ctx, events)
}
760042
func (b *UpdateBuilder) Add(column string) *UpdateBuilder {
	return b.addValue(column, param(column))
}
6432
func (s *Selection) Add(selector string) *Selection {
	return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, compileMatcher(selector))...)
}
178309
func (h *HTTPSink) AddEvents(ctx context.Context, events []*event.Event) (err error) {
	if len(events) == 0 || h.EventEndpoint == "" {
		return nil
	}
	return h.doBottom(ctx, func() (io.Reader, bool, error) {
		return h.encodePostBodyProtobufV2Events(events)
	}, "application/x-protobuf", h.EventEndpoint, datapointAndEventResponseValidator)
}