// Return a channel that is notified when Wait() returns.
193057
func (cmd AppCmd) waitChan() <-chan string {
	ch := make(chan string, 1)
	go func() {
		_ = cmd.Wait()
		state := cmd.ProcessState
		exitStatus := " unknown "
		if state != nil {
			exitStatus = state.String()
		}

		ch <- exitStatus
	}()
	return ch
}
194569
func wait() {
	const maxWait = 1 * time.Minute

	now := time.Now().UTC()
	mu.Lock()
	wait := getWaitTime(now, maxWait)
	mu.Unlock()

	time.Sleep(wait)

	interval := 500 * time.Millisecond
	if wait == maxWait {
		interval = maxWait
	}

	mu.Lock()
	defer mu.Unlock()
	if now.Before(nextProvision) {
		nextProvision = nextProvision.Add(interval)
		return
	}
	now = time.Now().UTC()
	nextProvision = now.Add(interval)
}
829764
func (_m *ChannelLister) Channels() []cluster.ChannelGenesisBlock {
	ret := _m.Called()

	var r0 []cluster.ChannelGenesisBlock
	if rf, ok := ret.Get(0).(func() []cluster.ChannelGenesisBlock); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]cluster.ChannelGenesisBlock)
		}
	}

	return r0
}
579148
func (d *pipeDeadline) wait() chan struct{} {
	d.mu.Lock()
	defer d.mu.Unlock()
	return d.cancel
}
770247
func WaitForAuthToken(cancel <-chan interface{}) <-chan struct{} {
	ch := make(chan struct{})
	go func() {
		for currentToken == "" {
			select {
			case <-cond.Wait():
			case <-cancel: // Receive from nil channel never returns, so this is fine
			}
		}
		close(ch)
	}()
	return ch
}
1132774
func unlock_notify_wait(db *C.sqlite3) C.int {
	// It has to be a bufferred channel to not block in sqlite_unlock_notify
	// as sqlite_unlock_notify could invoke the callback before it returns.
	c := make(chan struct{}, 1)
	defer close(c)

	h := unt.add(c)
	defer unt.remove(h)

	pargv := C.malloc(C.sizeof_uint)
	defer C.free(pargv)

	argv := (*[1]uint)(pargv)
	argv[0] = h
	if rv := C.sqlite3_unlock_notify(db, (*[0]byte)(C.unlock_notify_callback), unsafe.Pointer(pargv)); rv != C.SQLITE_OK {
		return rv
	}

	<-c

	return C.SQLITE_OK
}
1066344
func (bttvAPI *BTTVAPI) GetChannel(channelName string, onSuccess func(ChannelResponse),
	onHTTPError jsonapi.HTTPErrorCallback, onInternalError jsonapi.InternalErrorCallback) {
	var channel ChannelResponse
	onSuccessfulRequest := func() {
		onSuccess(channel)
	}
	bttvAPI.Get("/2/channels/"+channelName, nil, &channel, onSuccessfulRequest,
		onHTTPError, onInternalError)
}
427716
func (eb exponentialBackoff) wait() {
	time.Sleep(eb.currentDelay)
	eb.currentDelay = eb.b.Duration()
}
484024
func (rw *RetryWaiter) wait() <-chan struct{} {
	waitTime := rw.calculateWait()
	ch := make(chan struct{})
	if waitTime > 0 {
		time.AfterFunc(waitTime, func() { close(ch) })
	} else {
		// if there should be 0 wait time then we ensure
		// that the chan will be immediately selectable
		close(ch)
	}
	return ch
}
1324917
func (n *autodisc) wait() error {
	n.once.Do(func() {
		n.mu.Lock()
		n.found = n.doit()
		n.mu.Unlock()
	})
	if n.found == nil {
		return fmt.Errorf("no %s router discovered", n.what)
	}
	return nil
}
637514
func (info Info) GetChannelByID(channelID string) *Channel {
	for _, channel := range info.Channels {
		if channel.ID == channelID {
			return &channel
		}
	}
	return nil
}
1224376
func (wg *WaitGroup) Wait() []error {
	wg.wg.Wait()

	wg.mutex.Lock()
	defer wg.mutex.Unlock()

	if len(wg.errs) == 0 {
		return nil
	}
	return wg.errs
}
490576
func (s *persistentRemotes) WaitSelect(ctx context.Context) <-chan api.Peer {
	c := make(chan api.Peer, 1)
	s.RLock()
	done := make(chan struct{})
	go func() {
		select {
		case <-ctx.Done():
			s.c.Broadcast()
		case <-done:
		}
	}()
	go func() {
		defer s.RUnlock()
		defer close(c)
		defer close(done)
		for {
			if ctx.Err() != nil {
				return
			}
			p, err := s.Select()
			if err == nil {
				c <- p
				return
			}
			s.c.Wait()
		}
	}()
	return c
}
116530
func (c *client) Wait(id int64) *Wait {
	ctx, cancel := context.WithCancel(context.Background())
	return &Wait{id, c, ctx, cancel}
}
230835
func (tt *timeoutThread) waitForNonEmptyQueue() bool {
	tt.mu.Lock()
	queueNotEmpty := tt.queueNotEmpty
	tt.mu.Unlock()

	select {
	// a) Always check these channels, regardless of the state.
	case <-tt.maxDuration.C:
		// Max duration is up. Stop buffering. Do not error out entries explicitly.
		tt.sb.stopBufferingDueToMaxDuration()
		return true
	case <-tt.stopChan:
		// Failover ended before timeout. Do nothing.
		return true
	// b) State-specific check.
	case <-queueNotEmpty:
		// At least one entry present. Check its timeout in the next iteration.
		return false
	}
}
117992
func (s *Service) wait() {
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM, os.Kill)
	select {
	case sig := <-c:
		BootPrintln("[service] got signal:", sig)
	case <-s.stopper:
		BootPrintln("[service] app stop")
	}
	s.stop()
}
1173411
func (kcp *KCP) WaitSnd() int {
	return len(kcp.snd_buf) + len(kcp.snd_queue)
}