// NewCgroupNotifier creates a cgroup notifier that does nothing because cgroups do not exist on non-linux systems.
962340
func NewCgroupNotifier(path, attribute string, threshold int64) (CgroupNotifier, error) {
	klog.V(5).Infof("cgroup notifications not supported")
	return &unsupportedThresholdNotifier{}, nil
}
361535
func (g *groupRegistry) newGroup() *Group {
	c := &Group{
		g:        g,
		counters: make([]Counter, len(g.group.counters)),
		timers:   make([]Timer, len(g.group.timers)),
	}
	copy(c.counters, g.group.counters)
	copy(c.timers, g.group.timers)

	return c
}
122351
func (n *Notifier) Notifier(total uint) *Notifier {
	notifier := &Notifier{
		total:          total,
		current:        0,
		transaction:    nil,
		totalUpdates:   n.totalUpdates,
		notifications:  n.notifications,
		observerClosed: n.observerClosed,
		ctxDone:        n.ctxDone,
	}

	n.totalUpdates <- total
	return notifier
}
26671
func NewSyncFromNotifier(notifier *gobrake.Notifier) *Handler {
	handler := NewFromNotifier(notifier)

	handler.sendSynchronously = true

	return handler
}
965914
func NewNotifyWorker(handler NotifyWatchHandler) worker.Worker {
	nw := &notifyWorker{
		handler: handler,
	}

	nw.tomb.Go(nw.loop)
	return nw
}
124559
func NewGroupChangeExternalIdType(Description string) *GroupChangeExternalIdType {
	s := new(GroupChangeExternalIdType)
	s.Description = Description
	return s
}
809761
func (c *Controller) RemoveNotifier(name string) error {
	c.mu.Lock()
	defer c.mu.Unlock()
	currentNotifier, ok := c.notifiers[name]
	if !ok {
		return fmt.Errorf("Unknown notification service %s", name)
	}
	currentNotifier.removeSubscription()
	delete(c.notifiers, name)
	return nil
}
883792
func NewGroupInfo(GroupName string, GroupId string, GroupManagementType *team_common.GroupManagementType, GroupType *team_common.GroupType, IsMember bool, IsOwner bool, SameTeam bool) *GroupInfo {
	s := new(GroupInfo)
	s.GroupName = GroupName
	s.GroupId = GroupId
	s.GroupManagementType = GroupManagementType
	s.GroupType = GroupType
	s.IsMember = IsMember
	s.IsOwner = IsOwner
	s.SameTeam = SameTeam
	return s
}
397806
func (n *Notifier) Notify(eventType EventType, message string, increment bool) {
	notif := &notification{
		Type:      eventType,
		Message:   message,
		Increment: increment,
	}

	if increment {
		n.Lock()
		n.current++
		n.Unlock()
	}

	n.RLock()
	current := n.current
	total := n.total
	n.RUnlock()

	if current > total {
		panic(fmt.Sprintf(
			"notifications exceed maximum %d/%d", current, total))
	}

	select {
	case n.notifications <- notif:
		return
	case <-n.observerClosed:
		return
	case <-n.ctxDone:
		return
	}
}
458614
func (o *Observer) Notifier(ctx context.Context, total uint) (*Notifier, error) {

	if ctx == nil {
		return nil, errors.New("Context must be provided")
	}

	id, ok := ctx.Value(CtxRequestID).(string)
	if !ok {
		return nil, errors.New("Missing 'id' property in Context")
	}

	totalUpdates := make(chan uint)
	notifications := make(chan *notification)

	t := &transaction{
		requestID:      id,
		total:          total,
		current:        0,
		totalUpdates:   totalUpdates,
		events:         o.notify,
		notifications:  notifications,
		observerClosed: o.closed,
		ctxDone:        ctx.Done(),
	}

	t.start()

	n := &Notifier{
		total:          total,
		current:        0,
		transaction:    t,
		totalUpdates:   totalUpdates,
		notifications:  notifications,
		observerClosed: t.observerClosed,
		ctxDone:        t.ctxDone,
	}

	return n, nil
}
316131
func (ref *Consumer) notificationHandler(in <-chan *cluster.Notification) {
	ref.Debug("NotificationHandler started ...")

	for {
		select {
		case note := <-in:
			ref.Config.RecvNotificationChan <- note
		case <-ref.closeChannel:
			ref.Debug("Canceling notification handler")
			return
		}
	}
}
1096968
func (p *StatsProvider) GetCgroupCPUAndMemoryStats(cgroupName string, updateStats bool) (*statsapi.ContainerStats, error) {
	info, err := getCgroupInfo(p.cadvisor, cgroupName, updateStats)
	if err != nil {
		return nil, fmt.Errorf("failed to get cgroup stats for %q: %v", cgroupName, err)
	}
	// Rootfs and imagefs doesn't make sense for raw cgroup.
	s := cadvisorInfoToContainerCPUAndMemoryStats(cgroupName, info)
	return s, nil
}
519376
func NewWatcher() *Watcher {
	w := &Watcher{
		pins:         make(map[uintptr]Pin),
		fds:          fdHeap{},
		cmdChan:      make(chan watcherCmd, watcherCmdChanLen),
		Notification: make(chan WatcherNotification, notificationLen),
	}
	heap.Init(&w.fds)
	go w.watch()
	return w
}
903350
func NewGroup() Group {
	return Group{
		EnableAutoType:  w.BoolWrapper(true),
		EnableSearching: w.BoolWrapper(true),
		Times:           NewTimeData(),
		UUID:            NewUUID(),
	}
}
784896
func NewNotifyWorker(config NotifyConfig) (*NotifyWorker, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	nw := &NotifyWorker{
		config: config,
	}
	err := catacomb.Invoke(catacomb.Plan{
		Site: &nw.catacomb,
		Work: nw.loop,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return nw, nil
}
662412
func (s *Server) notifier() {
	var timer <-chan time.Time
	for {
		var err error
		select {
		case notification := <-s.notify:
			s.batch = append(s.batch, notification)
			// Collect until BatchDelay passes, or BatchSize are queued.
			switch len(s.batch) {
			case 1:
				timer = time.After(s.config.BatchDelay)
			case s.config.BatchSize:
				err = s.send()
				timer = nil
			}

		case <-timer:
			err = s.send()
		}

		if err != nil {
			log.Fatal(err)
		}
	}
}
1088291
func NewGroup(group string, client *cloudwatchlogs.CloudWatchLogs) *Group {
	return &Group{
		group:  group,
		client: client,
	}
}