// wait waits until the provided function returns true (or times out)
420016
func (r *marathonClient) wait(name string, timeout time.Duration, fn func(string) bool) error {
	timer := time.NewTimer(timeout)
	defer timer.Stop()

	ticker := time.NewTicker(r.config.PollingWaitTime)
	defer ticker.Stop()
	for {
		if fn(name) {
			return nil
		}

		select {
		case <-timer.C:
			return ErrTimeoutError
		case <-ticker.C:
			continue
		}
	}
}
957059
func (m *EventHandler) Wait(d time.Duration) bool {
	select {
	case <-m.Recv:
		return true
	case <-time.After(d):
		return false
	}
}
1022526
func (cond *TimeoutCond) Wait(ctx context.Context) bool {
	cond.addWaiter()
	//copy signal in lock, avoid data race with Interrupt
	ch := cond.signal
	//wait should unlock mutex,  if not will cause deadlock
	cond.L.Unlock()
	defer cond.removeWaiter()
	defer cond.L.Lock()

	select {
	case _, ok := <-ch:
		return !ok
	case <-ctx.Done():
		return false
	}
}
1303616
func (k *KCommand) Wait() error {
	if k.Process == nil {
		return errors.New("exec: not started")
	}
	k.once.Do(func() {
		if k.errCs == nil {
			k.errCs = make([]chan error, 0)
		}
		go func() {
			k.err = k.Cmd.Wait()
			k.mu.Lock()
			k.finished = true
			for _, errC := range k.errCs {
				errC <- k.err
			}
			k.mu.Unlock()
		}()
	})
	k.mu.Lock()
	if k.finished {
		k.mu.Unlock()
		return k.err
	}
	errC := make(chan error, 1)
	k.errCs = append(k.errCs, errC)
	k.mu.Unlock()
	return <-errC
}
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
}
116530
func (c *client) Wait(id int64) *Wait {
	ctx, cancel := context.WithCancel(context.Background())
	return &Wait{id, c, ctx, cancel}
}
32940
func (n *Node) Wait() {
	n.lock.RLock()
	if n.server == nil {
		n.lock.RUnlock()
		return
	}
	stop := n.stop
	n.lock.RUnlock()

	<-stop
}
1189655
func (t Term) Wait(optArgs ...WaitOpts) Term {
	opts := map[string]interface{}{}
	if len(optArgs) >= 1 {
		opts = optArgs[0].toMap()
	}
	return constructMethodTerm(t, "Wait", p.Term_WAIT, []interface{}{}, opts)
}
939629
func (c *connection) Wait() {
	if c.started {
		return
	}
	c.started = true
	// start the ping
	c.startPinger()

	// start the messages reader
	c.startReader()
}
1046211
func WaitFunc(wait func(context.Context, *cdp.Frame, ...cdp.NodeID) ([]*cdp.Node, error)) QueryOption {
	return func(s *Selector) {
		s.wait = wait
	}
}
474750
func (c *runCmd) Wait() error {
	defer func() {
		_ = os.Remove(c.tmpFile)
	}()

	err := c.Cmd.Wait()
	if err != nil {
		return err
	}
	return nil
}
1120084
func wait(pid int, rusage *syscall.Rusage) (int, *syscall.WaitStatus, error) {
	var status syscall.WaitStatus
	var siginfo [128]byte
	// If we can block until Wait4 will succeed immediately, do so.
	psig := &siginfo[0]
	_, _, e := syscall.Syscall6(syscall.SYS_WAITID, 1, uintptr(pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)
	// psig may be garbage collected before
	// syscall, KeepAlive make it alive util
	// sysacll return.
	runtime.KeepAlive(psig)
	if e != 0 {
		if e != syscall.ENOSYS {
			return 0, nil, os.NewSyscallError("waitid", e)
		}
	}
	wpid, err := syscall.Wait4(pid, &status, 0, rusage) // for rusage collect
	if err != nil {
		return 0, nil, err
	}
	return wpid, &status, err
}
214983
func (fuse Fuse) Wait() {
	fuse.signal.L.Lock()
	defer fuse.signal.L.Unlock()
	if fuse.IsBurned() {
		fuse.signal.Wait()
	}
}
674209
func (m *MockLocker) Wait(arg0 string) error {
	ret := m.ctrl.Call(m, "Wait", arg0)
	ret0, _ := ret[0].(error)
	return ret0
}
449814
func (c *SSHClient) Wait() error {
	if !c.running {
		return fmt.Errorf("Trying to wait on stopped session")
	}

	err := c.sess.Wait()
	c.sess.Close()
	c.running = false
	c.sessOpened = false

	return err
}
1275394
func (l *LibcontainerExecutor) Wait(ctx context.Context) (*ProcessState, error) {
	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	case <-l.userProcExited:
		return l.exitState, nil
	}
}
1107360
func (p *Process) wait() error {
	ticker := time.NewTicker(1000 * time.Millisecond)
	defer ticker.Stop()

	timer := time.NewTimer(30 * time.Second)
	defer ticker.Stop()

	for {
		select {
		case <-timer.C:
			return errors.New("timeout")
		case <-ticker.C:
			if err := p.ping(); err == nil {
				return nil
			}
		}
	}
}