// waitFor blocks until redis-server prints the given string to stdout.
332941
func (s *Server) waitFor(search string) (err error) {
	var line string

	scanner := bufio.NewScanner(s.stdout)
	for scanner.Scan() {
		line = scanner.Text()
		fmt.Fprintf(&s.stdoutBuf, "%s\n", line)
		if strings.Contains(line, search) {
			return nil
		}
	}
	err = scanner.Err()
	if err == nil {
		err = io.EOF
	}
	return err
}
1033798
func (p *FanOut) Wait() []error {
	// Wait for all the routines to complete
	for i := 0; i < cap(p.size); i++ {
		p.size <- true
	}
	// Close the err channel
	if p.errChan != nil {
		close(p.errChan)
	}

	// Wait until the error collector routine is complete
	p.wg.Wait()

	// If there are no errors
	if len(p.errs) == 0 {
		return nil
	}
	return p.errs
}
1199081
func (e *Element) WaitForReady() error {
	e.lock.RLock()
	ready := e.ready
	e.lock.RUnlock()

	if ready {
		return nil
	}

	timeout := time.NewTimer(e.tab.elementTimeout)
	defer timeout.Stop()

	select {
	case <-e.readyGate:
		return nil
	case <-timeout.C:
		return &ElementNotReadyErr{}
	}
}
478927
func WaitForImage(ctx context.Context, client *gophercloud.ServiceClient, imageId string) error {
	maxNumErrors := 10
	numErrors := 0

	for {
		if err := ctx.Err(); err != nil {
			return err
		}
		image, err := images.Get(client, imageId).Extract()
		if err != nil {
			errCode, ok := err.(*gophercloud.ErrUnexpectedResponseCode)
			if ok && (errCode.Actual == 500 || errCode.Actual == 404) {
				numErrors++
				if numErrors >= maxNumErrors {
					log.Printf("[ERROR] Maximum number of errors (%d) reached; failing with: %s", numErrors, err)
					return err
				}
				log.Printf("[ERROR] %d error received, will ignore and retry: %s", errCode.Actual, err)
				time.Sleep(2 * time.Second)
				continue
			}

			return err
		}

		if image.Status == "active" {
			return nil
		}

		log.Printf("Waiting for image creation status: %s", image.Status)
		time.Sleep(2 * time.Second)
	}
}
248402
func waitForPath(pool, image string, maxRetries int, useNbdDriver bool) (string, bool) {
	for i := 0; i < maxRetries; i++ {
		if i != 0 {
			time.Sleep(time.Second)
		}
		if useNbdDriver {
			if devicePath, found := getNbdDevFromImageAndPool(pool, image); found {
				return devicePath, true
			}
		} else {
			if devicePath, found := getRbdDevFromImageAndPool(pool, image); found {
				return devicePath, true
			}
		}
	}
	return "", false
}
961585
func (e *localExec) Wait() (*ExecResult, error) {
	if e.Cmd.Process == nil {
		e.Ctx.Errorf("no process")
	}

	// wait for the command to complete, then figure out if the command
	// successfully exited or if it exited in failure
	execResult, err := collectLocalStatus(e.Cmd, e.Cmd.Wait())

	// emit the result of execution to the audit log
	emitExecAuditEvent(e.Ctx, e.GetCommand(), execResult, err)

	return execResult, trace.Wrap(err)
}
787193
func (s *ExtensionManagerServer) waitStarted() {
	for {
		s.mutex.Lock()
		started := s.started
		s.mutex.Unlock()
		if started {
			time.Sleep(10 * time.Millisecond)
			break
		}
	}
}
848246
func (r *remoteExec) Wait() (*ExecResult, error) {
	// block until the command is finished and then figure out if the command
	// successfully exited or if it exited in failure
	execResult, err := r.collectRemoteStatus(r.session.Wait())

	// emit the result of execution to the audit log
	emitExecAuditEvent(r.ctx, r.command, execResult, err)

	return execResult, trace.Wrap(err)
}
217527
func (s semaphore) wait(ctx context.Context) error {
	// Always check Err first. "select" randomly selects a channel when both
	// channels are available, and we want to prioritize cancelation.
	if err := ctx.Err(); err != nil {
		return err
	}
	select {
	case <-ctx.Done():
		// Err() is guaranteed to be non-nil.
		return ctx.Err()
	case <-s:
		/*
			// Do a last check, just in case. It makes things slightly slower but
			// reduces the chance of race condition with having a spurious item running
			// after cancelation.
			if err := ctx.Err(); err != nil {
				s.signal()
				return err
			}
		*/
		return nil
	}
}
927937
func (p *Pool) Wait() error {
	p.wg.Wait()
	close(p.semaphore)

	return p.errors.Error()
}
751680
func (s *TasksListService) WaitForCompletion(waitForCompletion bool) *TasksListService {
	s.waitForCompletion = &waitForCompletion
	return s
}
97752
func (r *Run) Wait() error {
	r.wg.Wait()
	if len(r.errs) != 0 {
		return Errors(r.errs)
	}
	return nil
}
47239
func WaitForKey() {
	for {
		e := PollEvent()
		switch e.Type {
		case termbox.EventKey:
			switch e.Key {
			case termbox.KeyEsc, termbox.KeyEnter, termbox.KeySpace:
				return
			}
		}
	}
}
591938
func (r *RemoteCmd) Wait() int {
	r.initchan()
	<-r.exitCh
	r.Lock()
	defer r.Unlock()
	return r.exitStatus
}
99029
func WaitForResume() chan struct{} {
	ch := make(chan struct{})
	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		ticker := time.NewTicker(10 * time.Millisecond)
		t := time.Now()
		wg.Done()
		for {
			now := <-ticker.C
			if now.Sub(t) > 100*time.Millisecond {
				break
			}
			t = now
		}
		ticker.Stop()
		ch <- struct{}{}
	}()
	wg.Wait()
	return ch
}
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
	}
}
646575
func (g *GoroutinePriorityPool) Wait() error {
	g.wg.Wait()
	return g.ctx.Err()
}