// Wait for hangar. Incoming flights are stored, outgoing are sent to departure.
543613
func (a *Airport) processHangar() {
	for {
		hangar, ok := <-a.hangarChan
		if !ok {
			a.log.Errorf("hangar channel closed")
			return
		}
		switch hangar.GetChangeType() {
		case datasync.Put:
			a.log.Debugf("hangar %s updated", hangar.GetKey())
		case datasync.Delete:
			fl := flight.Info{}
			if _, err := fmt.Sscanf(hangar.GetKey(), hangarKeyTemplate, &(fl.Airline), &(fl.Number), &(fl.Priority)); err != nil {
				a.log.Errorf("error creating hangar key: %v", err)
				continue
			}
			if err := a.departureBroker.Put(fmt.Sprintf(flightIDFormat, fl.Airline, fl.Number), &fl); err != nil {
				a.log.Errorf("failed to put flight to departure broker: %v", err)
				continue
			}
		}
	}
}
900470
func (m *Command) Wait() error {
	// First SIGKILL causes server to shut down gracefully.
	c := make(chan os.Signal, 2)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
	select {
	case sig := <-c:
		m.logger.Printf("received signal '%s', gracefully shutting down...\n", sig.String())

		// Second signal causes a hard shutdown.
		go func() { <-c; os.Exit(1) }()
		return errors.Wrap(m.Close(), "closing command")
	case <-m.done:
		m.logger.Printf("server closed externally")
		return nil
	}
}
395209
func (f *tokenFuture) Wait() <-chan struct{} {
	f.m.Lock()
	defer f.m.Unlock()

	c := make(chan struct{})
	if f.set {
		close(c)
		return c
	}

	f.waiting = append(f.waiting, c)
	return c
}
643258
func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (*taskAPI.WaitResponse, error) {
	return nil, errdefs.ErrNotImplemented
}
309007
func (cwg *ControlWaitGroup) Waiting() int {
	cwg.mu.Lock()
	w := cwg.waiting
	cwg.mu.Unlock()
	return w
}
1175172
func (r *controller) Wait(pctx context.Context) error {
	if err := r.checkClosed(); err != nil {
		return err
	}

	ctx, cancel := context.WithCancel(pctx)
	defer cancel()

	healthErr := make(chan error, 1)
	go func() {
		ectx, cancel := context.WithCancel(ctx) // cancel event context on first event
		defer cancel()
		if err := r.checkHealth(ectx); err == ErrContainerUnhealthy {
			healthErr <- ErrContainerUnhealthy
			if err := r.Shutdown(ectx); err != nil {
				log.G(ectx).WithError(err).Debug("shutdown failed on unhealthy")
			}
		}
	}()

	waitC, err := r.adapter.wait(ctx)
	if err != nil {
		return err
	}

	if status := <-waitC; status.ExitCode() != 0 {
		exitErr := &exitError{
			code: status.ExitCode(),
		}

		// Set the cause if it is knowable.
		select {
		case e := <-healthErr:
			exitErr.cause = e
		default:
			if status.Err() != nil {
				exitErr.cause = status.Err()
			}
		}

		return exitErr
	}

	return nil
}
850507
func (wg *SafeWaitGroup) Wait() {
	wg.mu.Lock()
	wg.wait = true
	wg.mu.Unlock()
	wg.wg.Wait()
}
208232
func (a *Airport) processRunway(fl flight.Info) {
	flightID := fmt.Sprintf(flightIDFormat, fl.Airline, fl.Number)

	if fl.Status == flight.Status_arrival {
		a.log.Debugf("%s%s approaching runway\n", flightID, a.motions[fl.Status])
		_, err := a.arrivalBroker.Delete(flightID)
		if err != nil {
			a.log.Errorf("processRunway(%s) failed: %s", flightID, err)
		}
		a.land(fl)

		// send to departure or hangar
		if rand.Float64() <= hangarThreshold {
			err = a.hangarBroker.Put(makeHangarKey(fl), &fl, datasync.WithTTL(randomDuration(hangarDurationLow, hangarDurationHigh)))
		} else {
			err = a.departureBroker.Put(flightID, &fl)
		}
		if err != nil {
			a.log.Errorf("processRunway(%s) failed: %s", flightID, err)
		}
	} else {
		a.log.Debugf("%s%s approaching runway\n", flightID, a.motions[fl.Status])
		_, err := a.departureBroker.Delete(flightID)
		if err != nil {
			a.log.Errorf("processRunway(%s) failed: %s", flightID, err)
		}
		a.takeOff(fl)
		a.Lock()
		delete(a.flightRadar, flightID)
		a.Unlock()
	}
}
1133678
func (w *WindowedSchedule) Wait(last time.Time) Response {
	// If within the window we wait our interval and return
	// otherwise we exit with a completed state.
	var m uint

	if (last == time.Time{}) {
		// the first waiting in cycles, so
		// set the `stopOnTime` determining the right-window boundary
		w.setStopOnTime()
	}

	// Do we even have a specific start time?
	if w.StartTime != nil {
		// Wait till it is time to start if before the window start
		if time.Now().Before(*w.StartTime) {
			wait := w.StartTime.Sub(time.Now())
			logger.WithFields(log.Fields{
				"_block":         "windowed-wait",
				"sleep-duration": wait,
			}).Debug("Waiting for window to start")
			time.Sleep(wait)
		}
	}

	// Do we even have a stop time?
	if w.stopOnTime != nil {
		if time.Now().Before(*w.stopOnTime) {
			logger.WithFields(log.Fields{
				"_block":           "windowed-wait",
				"time-before-stop": w.stopOnTime.Sub(time.Now()),
			}).Debug("Within window, calling interval")

			m, _ = waitOnInterval(last, w.Interval)

			// check if the schedule should be ended after waiting on interval
			if time.Now().After(*w.stopOnTime) {
				logger.WithFields(log.Fields{
					"_block": "windowed-wait",
				}).Debug("schedule has ended")
				w.state = Ended
			}
		} else {
			logger.WithFields(log.Fields{
				"_block": "windowed-wait",
			}).Debug("schedule has ended")
			w.state = Ended
			m = 0
		}
	} else {
		// This has no end like a simple schedule
		m, _ = waitOnInterval(last, w.Interval)

	}
	return &WindowedScheduleResponse{
		state:    w.GetState(),
		missed:   m,
		lastTime: time.Now(),
	}
}
939629
func (c *connection) Wait() {
	if c.started {
		return
	}
	c.started = true
	// start the ping
	c.startPinger()

	// start the messages reader
	c.startReader()
}
427716
func (eb exponentialBackoff) wait() {
	time.Sleep(eb.currentDelay)
	eb.currentDelay = eb.b.Duration()
}
509861
func (container *container) Wait() error {
	err := container.system.Wait()
	if err == nil {
		err = container.system.ExitError()
	}
	return convertSystemError(err, container)
}
12437
func (p *Provider) wait() {
	// Compute the backoff time
	backoff := p.backoffDuration()

	// Setup a wait timer
	var wait <-chan time.Time
	if backoff > 0 {
		jitter := time.Duration(rand.Uint32()) % backoff
		wait = time.After(backoff + jitter)
	}

	// Wait until timer or shutdown
	select {
	case <-wait:
	case <-p.shutdownCh:
	}
}
591938
func (r *RemoteCmd) Wait() int {
	r.initchan()
	<-r.exitCh
	r.Lock()
	defer r.Unlock()
	return r.exitStatus
}
831764
func (k *kq) Wait() (interface{}, error) {
	var (
		kevn [1]syscall.Kevent_t
		err  error
	)
	kevn[0] = syscall.Kevent_t{}
	_, err = syscall.Kevent(k.fd, nil, kevn[:], nil)

	return kevn[0], err
}
924618
func Wait(b bool) Option {
	return func(o *Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, "wait", b)
	}
}
1007433
func Wait(waitables ...Waitable) error {
	g := NewGroup()
	g.Collect(waitables...)
	return g.Wait()
}