//Start is one of the two interface methods of GoGadget.  Start takes
//in in and out chan and is meant to be called as a goroutine.
341841
func (g *Gadget) Start(in <-chan Message, out chan<- Message) {
	g.out = out
	g.timerIn = make(chan bool)
	g.timerOut = make(chan bool)
	if g.Output != nil {
		if len(g.InitialValue) > 0 {
			g.readInitialValue()
		} else {
			g.off()
		}
		g.doOutputLoop(in)
	} else if g.Input != nil {
		g.doInputLoop(in)
	}
}
14981
func (m *Driver) Start() error {
	go func() {
		for {
			packet, err := m.adaptor().ReadMAVLinkPacket()
			if err != nil {
				m.Publish(ErrorIOEvent, err)
				continue
			}
			m.Publish(PacketEvent, packet)
			message, err := packet.MAVLinkMessage()
			if err != nil {
				m.Publish(ErrorMAVLinkEvent, err)
				continue
			}
			m.Publish(MessageEvent, message)
			time.Sleep(m.interval)
		}
	}()
	return nil
}
1314482
func (posixSignalManager *PosixSignalManager) Start(gs gracefulshutdown.GSInterface) error {
	go func() {
		c := make(chan os.Signal, 1)
		signal.Notify(c, posixSignalManager.signals...)

		// Block until a signal is received.
		<-c

		gs.StartShutdown(posixSignalManager)
	}()

	return nil
}
839999
func (c context) start(wait time.Duration, delay time.Duration) error {
	procPaths, err := c.lookupProcessPaths()
	if err != nil {
		return err
	}

	if err := OpenAppDarwin(procPaths.appPath, c.log); err != nil {
		c.log.Warningf("Error opening app: %s", err)
	}

	// Check to make sure processes started
	c.log.Debugf("Checking processes: %#v", procPaths)
	serviceProcErr := c.checkProcess(procPaths.serviceProcPath, wait, delay)
	kbfsProcErr := c.checkProcess(procPaths.kbfsProcPath, wait, delay)
	appProcErr := c.checkProcess(procPaths.appProcPath, wait, delay)

	return util.CombineErrors(serviceProcErr, kbfsProcErr, appProcErr)
}
1223265
func (proto *Protocol) Start() *Reply {
	proto.logf("Started session, switching to ESTABLISH state")
	proto.State = ESTABLISH
	return ReplyIdent(proto.Hostname + " " + proto.Ident)
}
329066
func (s *SimpleTimer) Start() {
	if s.start == nil {
		tmp := time.Now()
		s.start = &tmp
	}
}
871197
func (t *Thermometer) Start(in <-chan Message, out chan<- Value) {
	temperature := make(chan Value)

	e := make(chan error)
	go t.getTemperature(temperature, e)
	for {
		select {
		case <-in:
			// do nothing
		case val := <-temperature:
			out <- val
		case err := <-e:
			log.Println(fmt.Sprintf("error reading thermometer %s", t.devicePath), err)
		}
	}
}
2814
func (c *Client) Start() {
	u := c.url
	if c.LoggingEnabled {
		log.Println("Now observing changes on", u.String())
	}

	atomic.AddUint64(&(c.runID), 1)
	currentRunID := atomic.LoadUint64(&(c.runID))

	go func(runID uint64, u *url.URL) {
		since := time.Now().Unix() * 1000
		for {
			pr, err := c.fetchEvents(since)

			if err != nil {
				if c.LoggingEnabled {
					log.Println(err)
					log.Printf("Reattempting to connect to %s in %d seconds", u.String(), c.Reattempt)
				}
				time.Sleep(c.Reattempt)
				continue
			}

			// We check that its still the same runID as when this goroutine was started
			clientRunID := atomic.LoadUint64(&(c.runID))
			if clientRunID != runID {
				if c.LoggingEnabled {
					log.Printf("Client on URL %s has been stopped, not sending events", u.String())
				}
				return
			}

			if len(pr.Events) > 0 {
				if c.LoggingEnabled {
					log.Println("Got", len(pr.Events), "event(s) from URL", u.String())
				}
				for _, event := range pr.Events {
					since = event.Timestamp
					c.EventsChan <- event
				}
			} else {
				// Only push timestamp forward if its greater than the last we checked
				if pr.Timestamp > since {
					since = pr.Timestamp
				}
			}
		}
	}(currentRunID, u)
}
12057
func (b *MakeyButtonDriver) Start() (err error) {
	state := 1
	go func() {
		timer := time.NewTimer(b.interval)
		timer.Stop()
		for {
			newValue, err := b.connection.DigitalRead(b.Pin())
			if err != nil {
				b.Publish(Error, err)
			} else if newValue != state && newValue != -1 {
				state = newValue
				if newValue == 0 {
					b.Active = true
					b.Publish(ButtonPush, newValue)
				} else {
					b.Active = false
					b.Publish(ButtonRelease, newValue)
				}
			}
			timer.Reset(b.interval)
			select {
			case <-timer.C:
			case <-b.halt:
				return
			}
		}
	}()
	return
}
203061
func (s *BufferedSender) Start() {
	// write lock to start running
	s.runmx.Lock()
	defer s.runmx.Unlock()
	if s.running {
		return
	}

	s.running = true
	s.bufs = make(chan *bytes.Buffer, 32)
	go s.run()
}
105028
func (q *CtxQueue) Start(fn func(p interface{})) {
	// Make sure the queue can only be started once
	q.o.Do(func() {
		// Reset ctx
		atomic.StoreUint32(&q.ctxIsDone, 0)

		// Broadcast
		q.startC.L.Lock()
		q.startC.Broadcast()
		atomic.StoreUint32(&q.hasStarted, 1)
		q.startC.L.Unlock()

		// Wait is starting
		q.statListen.Add(true)

		// Loop
		for {
			select {
			case m := <-q.c:
				// Wait is done
				q.statListen.Done(true)

				// Check context
				if m.ctxIsDone {
					return
				}

				// Handle payload
				fn(m.p)

				// Broadcast the fact that the process is done
				m.c.L.Lock()
				m.c.Broadcast()
				m.c.L.Unlock()

				// Wait is starting
				q.statListen.Add(true)
			}
		}
	})
}
418236
func (m *SyncManager) Start() {
	m.start.Do(func() {
		m.wg.Add(1)
		go m.syncerHandler()
	})
}
402566
func (gs *GRPCSpanSink) Start(cl *trace.Client) error {
	gs.traceClient = cl

	// Run a background goroutine to do a little bit of connection state
	// tracking.
	go func() {
		for {
			// This call will block on a channel receive until the gRPC connection
			// state changes. When it does, flip the marker over to allow another
			// error to be logged from Ingest().
			gs.grpcConn.WaitForStateChange(ocontext.Background(), gs.grpcConn.GetState())
			atomic.StoreUint32(&gs.loggedSinceTransition, 0)
		}
	}()
	return nil
}
1100869
func (self *Container) Start() error {

	url := "container/" + self.Uuid + "/start/"
	request := "POST"
	//Empty Body Request
	body := []byte(`{}`)
	var response Container

	data, err := TutumCall(url, request, body)
	if err != nil {
		return err
	}

	err = json.Unmarshal(data, &response)
	if err != nil {
		return err
	}

	return nil
}
82327
func (s *Stater) Start(ctx context.Context) {
	// Make sure the stater can only be started once
	s.oStart.Do(func() {
		// Check context
		if ctx.Err() != nil {
			return
		}

		// Reset context
		s.ctx, s.cancel = context.WithCancel(ctx)

		// Reset once
		s.oStop = &sync.Once{}

		// Start stats
		for _, v := range s.ss {
			v.h.Start()
		}

		// Execute the rest in a go routine
		go func() {
			// Create ticker
			t := time.NewTicker(s.period)
			defer t.Stop()

			// Loop
			lastStatAt := time.Now()
			for {
				select {
				case <-t.C:
					// Get delta
					now := time.Now()
					delta := now.Sub(lastStatAt)
					lastStatAt = now

					// Loop through stats
					var stats []Stat
					for _, v := range s.ss {
						stats = append(stats, Stat{
							StatMetadata: v.m,
							Value:        v.h.Value(delta),
						})
					}

					// Handle stats
					go s.fn(stats)
				case <-s.ctx.Done():
					// Stop stats
					for _, v := range s.ss {
						v.h.Stop()
					}
					return
				}
			}
		}()
	})
}
1010149
func (a *AMQPConsumer) Start(acc telegraf.Accumulator) error {
	amqpConf, err := a.createConfig()
	if err != nil {
		return err
	}

	msgs, err := a.connect(amqpConf)
	if err != nil {
		return err
	}

	ctx, cancel := context.WithCancel(context.Background())
	a.cancel = cancel

	a.wg = &sync.WaitGroup{}
	a.wg.Add(1)
	go func() {
		defer a.wg.Done()
		a.process(ctx, msgs, acc)
	}()

	go func() {
		for {
			err := <-a.conn.NotifyClose(make(chan *amqp.Error))
			if err == nil {
				break
			}

			log.Printf("I! [inputs.amqp_consumer] connection closed: %s; trying to reconnect", err)
			for {
				msgs, err := a.connect(amqpConf)
				if err != nil {
					log.Printf("E! AMQP connection failed: %s", err)
					time.Sleep(10 * time.Second)
					continue
				}

				a.wg.Add(1)
				go func() {
					defer a.wg.Done()
					a.process(ctx, msgs, acc)
				}()
				break
			}
		}
	}()

	return nil
}
333161
func (d *Devices) Start() (err error) {
	log.Println("Starting devices...")
	for _, device := range *d {
		info := "Starting device " + device.Name()

		if pinner, ok := device.(Pinner); ok {
			info = info + " on pin " + pinner.Pin()
		}

		log.Println(info + "...")
		if derr := device.Start(); derr != nil {
			err = multierror.Append(err, derr)
		}
	}
	return err
}