// notifyIfAliased will notify waiters if this is a check for an aliased service
335173
func (l *State) notifyIfAliased(serviceID string) {
	if aliases, ok := l.checkAliases[serviceID]; ok && len(aliases) > 0 {
		for _, notifyCh := range aliases {
			// Do not block. All notify channels should be buffered to at
			// least 1 in which case not-blocking does not result in loss
			// of data because a failed send means a notification is
			// already queued. This must be called with the lock held.
			select {
			case notifyCh <- struct{}{}:
			default:
			}
		}
	}
}
775025
func (k *KeybaseServiceBase) Notify(ctx context.Context, notification *keybase1.FSNotification) error {
	// Reduce log spam by not repeating log lines for
	// notifications with the same filename.
	//
	// TODO: Only do this in debug mode.
	func() {
		k.lastNotificationFilenameLock.Lock()
		defer k.lastNotificationFilenameLock.Unlock()
		if notification.Filename != k.lastNotificationFilename {
			k.lastNotificationFilename = notification.Filename
			k.log.CDebugf(ctx, "Sending notification for %s", notification.Filename)
		}
	}()
	return k.kbfsClient.FSEvent(ctx, *notification)
}
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
	}
}
901005
func (k *KBPKIClient) Notify(ctx context.Context, notification *keybase1.FSNotification) error {
	return k.serviceOwner.KeybaseService().Notify(ctx, notification)
}
299684
func (m *wsNotificationManager) notifyFilteredBlockConnected(clients map[chan struct{}]*wsClient,
	block *btcutil.Block) {

	// Create the common portion of the notification that is the same for
	// every client.
	var w bytes.Buffer
	err := block.MsgBlock().Header.Serialize(&w)
	if err != nil {
		rpcsLog.Errorf("Failed to serialize header for filtered block "+
			"connected notification: %v", err)
		return
	}
	ntfn := btcjson.NewFilteredBlockConnectedNtfn(block.Height(),
		hex.EncodeToString(w.Bytes()), nil)

	// Search for relevant transactions for each client and save them
	// serialized in hex encoding for the notification.
	subscribedTxs := make(map[chan struct{}][]string)
	for _, tx := range block.Transactions() {
		var txHex string
		for quitChan := range m.subscribedClients(tx, clients) {
			if txHex == "" {
				txHex = txHexString(tx.MsgTx())
			}
			subscribedTxs[quitChan] = append(subscribedTxs[quitChan], txHex)
		}
	}
	for quitChan, wsc := range clients {
		// Add all discovered transactions for this client. For clients
		// that have no new-style filter, add the empty string slice.
		ntfn.SubscribedTxs = subscribedTxs[quitChan]

		// Marshal and queue notification.
		marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn)
		if err != nil {
			rpcsLog.Errorf("Failed to marshal filtered block "+
				"connected notification: %v", err)
			return
		}
		wsc.QueueNotification(marshalledJSON)
	}
}
461457
func (e *EventSubscriber) Notify(event *ct.Event) {
	if len(e.objectTypes) > 0 {
		foundType := false
		for _, typ := range e.objectTypes {
			if typ == string(event.ObjectType) {
				foundType = true
				break
			}
		}
		if !foundType {
			return
		}
	}
	if e.objectID != "" && e.objectID != event.ObjectID {
		return
	}
	select {
	case e.queue <- event:
	default:
		// Run in a goroutine to avoid deadlock with Notify
		go e.CloseWithError(ErrEventBufferOverflow)
	}
}
1207100
func (s *Swarm) Notify(n Notifiee) {
	s.notifieeLock.Lock()
	s.notifiees[n] = struct{}{}
	s.notifieeLock.Unlock()
}
134069
func (s *NotificationServer) notifySpentOutput(account uint32, op *wire.OutPoint, spenderHash *chainhash.Hash, spenderIndex uint32) {
	defer s.mu.Unlock()
	s.mu.Lock()
	clients := s.spentness[account]
	if len(clients) == 0 {
		return
	}
	n := &SpentnessNotifications{
		hash:         &op.Hash,
		index:        op.Index,
		spenderHash:  spenderHash,
		spenderIndex: spenderIndex,
	}
	for _, c := range clients {
		c <- n
	}
}
48615
func (k *KeybaseDaemonLocal) NotifySyncStatus(ctx context.Context,
	_ *keybase1.FSPathSyncStatus) error {
	return checkContext(ctx)
}
1222472
func (th *TlfHistory) AddUnflushedNotifications(
	loggedInUser string, msgs []NotificationMessage) {
	th.lock.Lock()
	defer th.lock.Unlock()
	if th.unflushed == nil {
		th.unflushed = &writerNotifications{loggedInUser, nil, nil}
	}
	if th.unflushed.writerName != loggedInUser {
		panic(fmt.Sprintf("Logged-in user %s doesn't match unflushed user %s",
			loggedInUser, th.unflushed.writerName))
	}
	newEdits := append(
		notificationsByRevision(msgs), th.unflushed.notifications...)
	sort.Sort(newEdits)
	th.unflushed.notifications = newEdits.uniquify()
	// Invalidate the cached results.
	th.computed = false
	th.cachedLoggedInUser = ""
}
357024
func (l *labelIdentitySelector) notifyUsers(added, deleted []identity.NumericIdentity) {
	for user := range l.users {
		user.IdentitySelectionUpdated(l, l.GetSelections(), added, deleted)
	}
}
37315
func (d *Daemon) NotifyChange(ctx context.Context, change v9.Change) error {
	switch change.Kind {
	case v9.GitChange:
		gitUpdate := change.Source.(v9.GitUpdate)
		if gitUpdate.URL != d.Repo.Origin().URL && gitUpdate.Branch != d.GitConfig.Branch {
			// It isn't strictly an _error_ to be notified about a repo/branch pair
			// that isn't ours, but it's worth logging anyway for debugging.
			d.Logger.Log("msg", "notified about unrelated change",
				"url", gitUpdate.URL,
				"branch", gitUpdate.Branch)
			break
		}
		d.Repo.Notify()
	case v9.ImageChange:
		imageUpdate := change.Source.(v9.ImageUpdate)
		d.ImageRefresh <- imageUpdate.Name
	}
	return nil
}
395358
func (k KeybaseServiceMeasured) NotifyOnlineStatusChanged(
	ctx context.Context, online bool) (err error) {
	k.notifyTimer.Time(func() {
		err = k.delegate.NotifyOnlineStatusChanged(ctx, online)
	})
	return err
}
193165
func (s Service) NotifyWithHeaders(subject, body string, headers map[string][]string) error {
	if len(s.NotifyAddresses) == 0 {
		return nil
	}
	return s.SendEmailWithHeaders(s.DefaultFrom, s.NotifyAddresses, s.SubjectPrefix+subject, body, headers)
}
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)
		}
	}
}
1096423
func (m *scopedManager) CloseNotify() <-chan bool {
	if w, ok := m.ResponseWriter.(http.CloseNotifier); ok {
		return w.CloseNotify()
	}
	return nil
}
679010
func (w *Watcher) Notify() *utils.Error {
	if w.serial {
		// Serialize Notify() calls.
		w.notifyMutex.Lock()
		defer w.notifyMutex.Unlock()
	}

	for i, watcher := range w.watchers {
		listener := w.listeners[i]

		// Pull all pending events / errors from the watcher.
		refresh := false
		for {
			select {
			case ev := <-watcher.Events:
				if w.rebuildRequired(ev, listener) {
					refresh = true
				}
				continue
			case <-watcher.Errors:
				continue
			default:
				// No events left to pull
			}
			break
		}

		utils.Logger.Info("Watcher:Notify refresh state", "Current Index", i, " last error index", w.lastError)
		if w.forceRefresh || refresh || w.lastError == i {
			var err *utils.Error
			if w.serial {
				err = listener.Refresh()
			} else {
				err = w.notifyInProcess(listener)
			}
			if err != nil {
				w.lastError = i
				w.forceRefresh = true
				return err
			} else {
				w.lastError = -1
				w.forceRefresh = false
			}
		}
	}

	return nil
}