//START COLLISION HANDLERS
324563
func circle2circle(contacts []*Contact, sA, sB *Shape) int {
	csA, ok := sA.ShapeClass.(*CircleShape)
	if !ok {
		log.Printf("Error: ShapeA not a CircleShape!")
		return 0
	}
	csB, ok := sB.ShapeClass.(*CircleShape)
	if !ok {
		log.Printf("Error: ShapeA not a CircleShape!")
		return 0
	}
	return circle2circleQuery(csA.Tc, csB.Tc, csA.Radius, csB.Radius, contacts[0])
}
514967
func (c *Consumer) Start(debug bool) error {
	if debug {
		for i := range c.handlers {
			log.Printf("Handler: topic=%s channel=%s\n", i.topic, i.channel)
		}
	}
	<-make(chan bool)
	return nil
}
562981
func (buf *Buffer) Start() error {
	if buf.pos <= 0 {
		return nil
	}

	buf.pos = 0
	return buf.Refresh()
}
470644
func (a *Astilectron) Start() (err error) {
	// Log
	astilog.Debug("Starting...")

	// Provision
	if err = a.provision(); err != nil {
		return errors.Wrap(err, "provisioning failed")
	}

	// Unfortunately communicating with Electron through stdin/stdout doesn't work on Windows so all communications
	// will be done through TCP
	if err = a.listenTCP(); err != nil {
		return errors.Wrap(err, "listening failed")
	}

	// Execute
	if err = a.execute(); err != nil {
		err = errors.Wrap(err, "executing failed")
		return
	}
	return
}
784354
func (w *Worker) Start() error {
	w.started.Do(func() {
		w.wg.Add(1)
		go w.requestHandler()
	})
	return nil
}
1091700
func (r *Robots) Start(args ...interface{}) (err error) {
	autoRun := true
	if args[0] != nil {
		autoRun = args[0].(bool)
	}
	for _, robot := range *r {
		if rerr := robot.Start(autoRun); rerr != nil {
			err = multierror.Append(err, rerr)
			return
		}
	}
	return
}
1199250
func (imu *IMUDriver) Start() (err error) {
	imu.connection.On("SysexResponse", func(res interface{}) {
		data := res.([]byte)
		imu.handleEvent(data)
	})
	return
}
1154486
func (pb *PingBatcher) start() {
	pb.tomb.Go(func() error {
		err := pb.loop()
		cause := errors.Cause(err)
		// tomb expects ErrDying or ErrStillAlive as
		// exact values, so we need to log and unwrap
		// the error first.
		if err != nil && cause != tomb.ErrDying {
			logger.Infof("ping batching loop failed: %v", err)
		}
		return cause
	})
}
901847
func (p *Service) Start(telegraf.Accumulator) (err error) {
	const localhost = "host=localhost sslmode=disable"

	if p.Address == "" || p.Address == "localhost" {
		p.Address = localhost
	}

	connectionString := p.Address

	// Specific support to make it work with PgBouncer too
	// See https://github.com/influxdata/telegraf/issues/3253#issuecomment-357505343
	if p.IsPgBouncer {
		d := &stdlib.DriverConfig{
			ConnConfig: pgx.ConnConfig{
				PreferSimpleProtocol: true,
				RuntimeParams: map[string]string{
					"client_encoding": "UTF8",
				},
				CustomConnInfo: func(c *pgx.Conn) (*pgtype.ConnInfo, error) {
					info := c.ConnInfo.DeepCopy()
					info.RegisterDataType(pgtype.DataType{
						Value: &pgtype.OIDValue{},
						Name:  "int8OID",
						OID:   pgtype.Int8OID,
					})

					return info, nil
				},
			},
		}
		stdlib.RegisterDriverConfig(d)
		connectionString = d.ConnectionString(p.Address)
	}

	if p.DB, err = sql.Open("pgx", connectionString); err != nil {
		return err
	}

	p.DB.SetMaxOpenConns(p.MaxOpen)
	p.DB.SetMaxIdleConns(p.MaxIdle)
	p.DB.SetConnMaxLifetime(p.MaxLifetime.Duration)

	return nil
}
879612
func (l *Lifecycle) Start(ctx context.Context) error {
	for _, hook := range l.hooks {
		if hook.OnStart != nil {
			l.logger.Printf("START\t\t%s()", hook.caller)
			if err := hook.OnStart(ctx); err != nil {
				return err
			}
		}
		l.numStarted++
	}
	return nil
}
1296009
func (g *Driver) Start() (err error) {
	bus := g.GetBusOrDefault(g.connector.GetSpiDefaultBus())
	chip := g.GetChipOrDefault(g.connector.GetSpiDefaultChip())
	mode := g.GetModeOrDefault(g.connector.GetSpiDefaultMode())
	bits := g.GetBitsOrDefault(g.connector.GetSpiDefaultBits())
	maxSpeed := g.GetSpeedOrDefault(g.connector.GetSpiDefaultMaxSpeed())

	g.connection, err = g.connector.GetSpiConnection(bus, chip, mode, bits, maxSpeed)
	if err != nil {
		return err
	}
	return nil
}
33968
func (b *Driver) Start() (err error) {
	b.adaptor().WithoutResponses(true)
	b.Init()
	b.FlatTrim()
	b.StartPcmd()
	b.FlatTrim()

	return
}
849064
func (q *Query) Start(start int) {
	q.params.Set("start", fmt.Sprintf("%d", start))
}
1328991
func (a *Agent) Start(ctx context.Context) error {
	err := errAgentStarted

	a.startOnce.Do(func() {
		close(a.started)
		go a.run(ctx)
		err = nil // clear error above, only once.
	})

	return err
}
97251
func (f *asyncFlusher) start(numParallel int) {
	f.chunks = make(chan chunk)
	for i := 0; i < numParallel; i++ {
		f.wg.Add(1)
		go func() {
			defer f.wg.Done()
			f.uploaderLoop()
		}()
	}
}
1067885
func (kc *KubeClient) StartGame(game *models.Game) (*api.Pod, error) {
	pod := createGamePod(game)
	log.Printf("Starting Game! Spec:\n%v", pod)
	return kc.client.Pods(api.NamespaceDefault).Create(pod)
}
619029
func (r *controller) Start(ctx context.Context) error {
	if err := r.checkClosed(); err != nil {
		return err
	}

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

	// Detect whether the container has *ever* been started. If so, we don't
	// issue the start.
	//
	// TODO(stevvooe): This is very racy. While reading inspect, another could
	// start the process and we could end up starting it twice.
	if ctnr.State.Status != "created" {
		return exec.ErrTaskStarted
	}

	if err := r.adapter.start(ctx); err != nil {
		return errors.Wrap(err, "starting container failed")
	}

	// no health check
	if ctnr.Config == nil || ctnr.Config.Healthcheck == nil {
		return nil
	}

	healthCmd := ctnr.Config.Healthcheck.Test

	if len(healthCmd) == 0 {
		// this field should be filled, even if inherited from image
		// if it's empty, health check will always be at starting status
		// so treat it as no health check, and return directly
		return nil
	}

	// health check is disabled
	if healthCmd[0] == "NONE" {
		return nil
	}

	// wait for container to be healthy
	eventq, closed, err := r.adapter.events(ctx)
	if err != nil {
		return err
	}
	for {
		select {
		case event := <-eventq:
			if !r.matchevent(event) {
				continue
			}

			switch event.Action {
			case "die": // exit on terminal events
				ctnr, err := r.adapter.inspect(ctx)
				if err != nil {
					return errors.Wrap(err, "die event received")
				}

				return makeExitError(ctnr)
			case "destroy":
				// If we get here, something has gone wrong but we want to exit
				// and report anyways.
				return ErrContainerDestroyed

			case "health_status: unhealthy":
				// in this case, we stop the container and report unhealthy status
				// TODO(runshenzhu): double check if it can cause a dead lock issue here
				if err := r.Shutdown(ctx); err != nil {
					return errors.Wrap(err, "unhealthy container shutdown failed")
				}
				return ErrContainerUnhealthy

			case "health_status: healthy":
				return nil
			}
		case <-closed:
			// restart!
			eventq, closed, err = r.adapter.events(ctx)
			if err != nil {
				return err
			}
		case <-ctx.Done():
			return ctx.Err()
		case <-r.closed:
			return r.err
		}
	}
}