// Run runs the ticker.
555847
func (t *Ticker) Run() {
	// predeclare some vars
	var (
		i, pos, nameLen int
		v               byte
		n               uint64
		err             error
		inf             Info
	)
	// ticker
	for {
		select {
		case <-t.Done:
			return
		case <-t.C:
			err = t.Profiler.Reset()
			if err != nil {
				t.Errs <- err
				continue
			}
			inf.Timestamp = time.Now().UTC().UnixNano()
			for {
				t.Val = t.Val[:0]
				t.Line, err = t.ReadSlice('\n')
				if err != nil {
					if err == io.EOF {
						break
					}
					t.Errs <- &joe.ReadError{Err: err}
				}
				// first grab the key name (everything up to the ':')
				for i, v = range t.Line {
					if v == ':' {
						pos = i + 1
						break
					}
					t.Val = append(t.Val, v)
				}
				nameLen = len(t.Val)

				// skip all spaces
				for i, v = range t.Line[pos:] {
					if v != ' ' {
						pos += i
						break
					}
				}

				// grab the numbers
				for _, v = range t.Line[pos:] {
					if v == ' ' || v == '\n' {
						break
					}
					t.Val = append(t.Val, v)
				}
				// any conversion error results in 0
				n, err = helpers.ParseUint(t.Val[nameLen:])
				if err != nil {
					t.Errs <- &joe.ParseError{Info: string(t.Val[:nameLen]), Err: err}
				}

				v = t.Val[0]
				// evaluate the key
				if v == 'A' {
					if t.Val[5] == 'e' {
						if nameLen == 6 {
							inf.Active = n
							continue
						}
						if t.Val[7] == 'a' {
							inf.ActiveAnon = n
							continue
						}
						inf.ActiveFile = n
						continue
					}
					if nameLen == 9 {
						inf.AnonPages = n
						continue
					}
					inf.AnonHugePages = n
					continue
				}
				if v == 'C' {
					if nameLen == 6 {
						inf.Cached = n
						continue
					}
					if nameLen == 11 {
						inf.CommitLimit = n
						continue
					}
					inf.CommittedAS = n
					continue
				}
				if v == 'D' {
					if nameLen == 5 {
						inf.Dirty = n
						continue
					}
					if t.Val[10] == 'k' {
						inf.DirectMap4K = n
						continue
					}
					inf.DirectMap2M = n
					continue
				}
				if v == 'H' {
					if nameLen == 14 {
						if t.Val[10] == 'F' {
							inf.HugePagesFree = n
							continue
						}
						if t.Val[10] == 'R' {
							inf.HugePagesRsvd = n
							continue
						}
						inf.HugePagesSurp = n
					}
					if t.Val[1] == 'a' {
						inf.HardwareCorrupted = n
						continue
					}
					if t.Val[9] == 'i' {
						inf.HugePagesSize = n
						continue
					}
					inf.HugePagesTotal = n
					continue
				}
				if v == 'I' {
					if nameLen == 8 {
						inf.Inactive = n
						continue
					}
					if t.Val[9] == 'a' {
						inf.InactiveAnon = n
						continue
					}
					inf.InactiveFile = n
				}
				if v == 'M' {
					v = t.Val[3]
					if nameLen < 8 {
						if v == 'p' {
							inf.Mapped = n
							continue
						}
						if v == 'F' {
							inf.MemFree = n
							continue
						}
						inf.Mlocked = n
						continue
					}
					if v == 'A' {
						inf.MemAvailable = n
						continue
					}
					inf.MemTotal = n
					continue
				}
				if v == 'S' {
					v = t.Val[1]
					if v == 'w' {
						if t.Val[4] == 'C' {
							inf.SwapCached = n
							continue
						}
						if t.Val[4] == 'F' {
							inf.SwapFree = n
							continue
						}
						inf.SwapTotal = n
						continue
					}
					if v == 'h' {
						inf.Shmem = n
						continue
					}
					if v == 'l' {
						inf.Slab = n
						continue
					}
					if v == 'R' {
						inf.SReclaimable = n
						continue
					}
					inf.SUnreclaim = n
					continue
				}
				if v == 'V' {
					if t.Val[8] == 'C' {
						inf.VmallocChunk = n
						continue
					}
					if t.Val[8] == 'T' {
						inf.VmallocTotal = n
						continue
					}
					inf.VmallocUsed = n
					continue
				}
				if v == 'W' {
					if nameLen == 9 {
						inf.Writeback = n
						continue
					}
					inf.WritebackTmp = n
					continue
				}
				if v == 'B' {
					if nameLen == 6 {
						inf.Bounce = n
						continue
					}
					inf.Buffers = n
					continue
				}
				if v == 'K' {
					inf.KernelStack = n
					continue
				}
				if v == 'N' {
					inf.NFSUnstable = n
					continue
				}
				if v == 'P' {
					inf.PageTables = n
				}
				inf.Unevictable = n
			}
			t.Data <- inf
		}
	}
}
628163
func (mrr *MultiRoutineRunner) Run(fn func()) {
	mrr.once.Do(mrr.init)
	mrr.q <- fn
}
371131
func (config *Config) Run(cmd string) (string, error) {
	if config.DisplayOutput == true {
		fmt.Printf("run: %s\n", cmd)
	}
	return config.doRun(cmd, false)
}
165566
func (t *Ticker) Run() {
	var (
		i, priorPos, pos, line, fieldNum int
		n                                uint64
		v                                byte
		err                              error
		dev                              structs.Device
		cur                              structs.DiskStats
	)
	// ticker
	for {
		select {
		case <-t.Done:
			return
		case <-t.C:
			cur.Timestamp = time.Now().UTC().UnixNano()
			err = t.Reset()
			if err != nil {
				t.Errs <- err
				break
			}
			cur.Device = cur.Device[:0]
			// read each line until eof
			for {
				t.Val = t.Val[:0]
				t.Line, err = t.ReadSlice('\n')
				if err != nil {
					if err == io.EOF {
						break
					}
					t.Errs <- &joe.ReadError{Err: err}
					break
				}
				line++
				pos = 0
				fieldNum = 0
				// process the fields in the line
				for {
					// ignore spaces on the first two fields
					if fieldNum < 2 {
						for i, v = range t.Line[pos:] {
							if v != 0x20 {
								break
							}
						}
						pos += i
					}
					fieldNum++
					for i, v = range t.Line[pos:] {
						if v == 0x20 || v == '\n' {
							break
						}
					}
					if fieldNum != 3 {
						n, err = helpers.ParseUint(t.Line[pos : pos+i])
						if err != nil {
							t.Errs <- &joe.ParseError{Info: fmt.Sprintf("line %d: field %d", line, fieldNum), Err: err}
							continue
						}
					}
					priorPos, pos = pos, pos+i+1
					if fieldNum < 8 {
						if fieldNum < 4 {
							if fieldNum < 2 {
								if fieldNum == 1 {
									dev.Major = uint32(n)
									continue
								}
								dev.Minor = uint32(n)
								continue
							}
							dev.Name = string(t.Line[priorPos:pos])
							continue
						}
						if fieldNum < 6 {
							if fieldNum == 4 {
								dev.ReadsCompleted = n
								continue
							}
							dev.ReadsMerged = n
							continue
						}
						if fieldNum == 6 {
							dev.ReadSectors = n
							continue
						}
						dev.ReadingTime = n
						continue
					}
					if fieldNum < 12 {
						if fieldNum < 10 {
							if fieldNum == 8 {
								dev.WritesCompleted = n
								continue
							}
							dev.WritesMerged = n
							continue
						}
						if fieldNum == 10 {
							dev.WrittenSectors = n
							continue
						}
						dev.WritingTime = n
						continue
					}
					if fieldNum == 12 {
						dev.IOInProgress = int32(n)
						continue
					}
					if fieldNum == 13 {
						dev.IOTime = n
						continue
					}
					dev.WeightedIOTime = n
					break
				}
				cur.Device = append(cur.Device, dev)
			}
			t.Data <- t.CalculateUsage(&cur)
			// set prior info
			t.prior.Timestamp = cur.Timestamp
			if len(t.prior.Device) != len(cur.Device) {
				t.prior.Device = make([]structs.Device, len(cur.Device))
			}
			copy(t.prior.Device, cur.Device)
		}
	}
}
1083941
func (p *FanOut) Run(callBack func(interface{}) error, data interface{}) {
	p.size <- true
	go func() {
		err := callBack(data)
		if err != nil {
			p.errChan <- err
		}
		<-p.size
	}()
}
123687
func (s *Server) Run() {
	var err error

	addr := s.config.Get("server.host") + ":" + s.config.Get("server.port")
	log.Printf("Listening on address: %q", addr)

	s.net, err = net.Listen("tcp", addr)
	if err != nil {
		log.Fatal(err)
	}
	defer s.net.Close()

	// Start server ticker
	go s.doTick()

	for !s.working {
		// Wait for a connection.
		conn, err := s.net.Accept()
		if err != nil {
			log.Println(err)
		}

		// Handle the connection in a new goroutine.
		// Multiple connections may be served concurrently.
		go s.handle(conn)
	}
}
656895
func (m *Main) Run() error {
	if m.Seed == -1 {
		m.Seed = time.Now().UnixNano()
	}

	src := fake.NewSource(m.Seed, m.GenConcurrency, m.Num)

	parser := pdk.NewDefaultGenericParser()
	if len(m.SubjectPath) == 0 {
		parser.Subjecter = pdk.BlankSubjecter{}
	} else {
		parser.EntitySubjecter = pdk.SubjectPath(m.SubjectPath)
	}

	mapper := pdk.NewCollapsingMapper()
	mapper.Framer = &m.Framer

	indexer, err := pdk.SetupPilosa(m.PilosaHosts, m.Index, nil, m.BatchSize)
	if err != nil {
		return errors.Wrap(err, "setting up Pilosa")
	}

	ingester := pdk.NewIngester(src, parser, mapper, indexer)
	go func() {
		err = pdk.StartMappingProxy(m.Proxy, pdk.NewPilosaForwarder(m.PilosaHosts[0], mapper.Translator))
		log.Fatal(errors.Wrap(err, "starting mapping proxy"))
	}()
	return errors.Wrap(ingester.Run(), "running ingester")
}
819547
func (m *Main) Run() (err error) {
	go func() {
		fmt.Println(http.ListenAndServe("localhost:6060", nil))
	}()

	schema := gopilosa.NewSchema()
	m.index = schema.Index(m.Index)
	pdk.NewRankedField(m.index, "weather_condition", 0)
	pdk.NewRankedField(m.index, "precipitation_type", 0)
	pdk.NewRankedField(m.index, "precipitation_inches", 0)
	pdk.NewRankedField(m.index, "temp_f", 0)
	pdk.NewRankedField(m.index, "pressure_i", 0)
	pdk.NewRankedField(m.index, "humidity", 0)

	m.importer, err = pdk.SetupPilosa([]string{m.PilosaHost}, m.Index, schema, uint(m.BufferSize))
	if err != nil {
		return errors.Wrap(err, "setting up pilosa")
	}

	pilosaURI, err := gopilosa.NewURIFromAddress(m.PilosaHost)
	if err != nil {
		return fmt.Errorf("interpreting pilosaHost '%v': %v", m.PilosaHost, err)
	}
	setupClient, err := gopilosa.NewClient(pilosaURI)
	if err != nil {
		return fmt.Errorf("setting up client: %v", err)
	}
	m.client = setupClient

	readFieldNames := []string{"cab_type", "passenger_count", "total_amount_dollars", "pickup_time", "pickup_day", "pickup_mday", "pickup_month", "pickup_year", "drop_time", "drop_day", "drop_mday", "drop_month", "drop_year", "dist_miles", "duration_minutes", "speed_mph", "pickup_grid_id", "drop_grid_id"}

	for _, fieldName := range readFieldNames {
		m.index.Field(fieldName)
	}
	err = setupClient.SyncSchema(schema)
	if err != nil {
		return errors.Wrap(err, "synchronizing schema")
	}

	err = m.WeatherCache.ReadAll()
	if err != nil {
		return errors.Wrap(err, "reading weather cache")
	}

	err = m.appendWeatherData()
	if err != nil {
		return errors.Wrap(err, "appending weather data")
	}

	return errors.Wrap(m.importer.Close(), "closing indexer")
}
460148
func (mod *HorizonBoxBee) Run(cin chan bees.Event) {
	mod.eventChan = cin
	for {
		select {
		case <-mod.SigChan:
			return

		case <-time.After(time.Duration(mod.interval) * time.Second):
			mod.poll()
		}
	}
}
577572
func (s *StepperDriver) Run() (err error) {
	//halt if already moving
	if s.moving == true {
		s.Halt()
	}

	s.mutex.Lock()
	s.moving = true
	s.mutex.Unlock()

	go func() {
		for {
			if s.moving == false {
				break
			}
			s.step()
		}
	}()

	return
}
707055
func (tm *transactionManager) run() {
	var q *query

	for {
		select {
		case q = <-tm.queryChan:
			go tm.query(q, tm.dht.Try)
		}
	}
}
203261
func (dht *DHT) Run() {
	dht.init()
	dht.listen()
	dht.join()

	dht.Ready = true

	var pkt packet
	tick := time.Tick(dht.CheckKBucketPeriod)

	for {
		select {
		case pkt = <-dht.packets:
			handle(dht, pkt)
		case <-tick:
			if dht.routingTable.Len() == 0 {
				dht.join()
			} else if dht.transactionManager.len() == 0 {
				go dht.routingTable.Fresh()
			}
		}
	}
}
747831
func (o *FlagOption) Run(value string) error {
	if err := o.flags.Parse(value); err != nil {
		return err
	}
	return nil
}
1068337
func (u *DropsondeUnmarshallerCollection) Run(inputChan <-chan []byte, outputChan chan<- *events.Envelope, waitGroup *sync.WaitGroup) {
	for _, unmarshaller := range u.unmarshallers {
		go func(um *DropsondeUnmarshaller) {
			defer waitGroup.Done()
			um.Run(inputChan, outputChan)
		}(unmarshaller)
	}
}
972710
func (mod *FacebookBee) Run(eventChan chan bees.Event) {
	mod.evchan = eventChan

	since := strconv.FormatInt(time.Now().UTC().Unix(), 10)
	timeout := time.Duration(10 * time.Second)

	for {
		select {
		case <-mod.SigChan:
			return
		case <-time.After(time.Duration(timeout)):
			var err error
			since, err = mod.handleStream(since)
			if err != nil {
				panic(err)
			}
		}

		timeout = time.Minute
	}
}
314164
func (t *Ticker) Run() {
	// predeclare some vars
	var (
		i, pos, nameLen int
		v               byte
		n               uint64
		err             error
	)
	// ticker
Tick:
	for {
		select {
		case <-t.Done:
			return
		case <-t.C:
			t.Builder.Reset()
			err = t.Profiler.Profiler.Reset()
			if err != nil {
				t.Errs <- err
				continue
			}
			structs.InfoStart(t.Builder)
			structs.InfoAddTimestamp(t.Builder, time.Now().UTC().UnixNano())
			for {
				t.Val = t.Val[:0]
				t.Line, err = t.ReadSlice('\n')
				if err != nil {
					if err == io.EOF {
						break
					}
					// An error results in sending error message and stop processing of this tick.
					t.Errs <- &joe.ReadError{Err: err}
					continue Tick
				}
				// first grab the key name (everything up to the ':')
				for i, v = range t.Line {
					if v == 0x3A {
						t.Val = t.Line[:i]
						pos = i + 1 // skip the :
						break
					}
				}
				nameLen = len(t.Val)
				// skip all spaces
				for i, v = range t.Line[pos:] {
					if v != 0x20 {
						pos += i
						break
					}
				}

				// grab the numbers
				for _, v = range t.Line[pos:] {
					if v == 0x20 || v == '\n' {
						break
					}
					t.Val = append(t.Val, v)
				}
				// any conversion error results in 0
				n, err = helpers.ParseUint(t.Val[nameLen:])
				if err != nil {
					t.Errs <- &joe.ParseError{Info: string(t.Val[:nameLen]), Err: err}
					continue
				}
				v = t.Val[0]
				if v == 'A' {
					if t.Val[5] == 'e' {
						if nameLen == 6 {
							structs.InfoAddActive(t.Builder, n)
							continue
						}
						if t.Val[7] == 'a' {
							structs.InfoAddActiveAnon(t.Builder, n)
							continue
						}
						structs.InfoAddActiveFile(t.Builder, n)
						continue
					}
					if nameLen == 9 {
						structs.InfoAddAnonPages(t.Builder, n)
						continue
					}
					structs.InfoAddAnonHugePages(t.Builder, n)
					continue
				}
				if v == 'C' {
					if nameLen == 6 {
						structs.InfoAddCached(t.Builder, n)
						continue
					}
					if nameLen == 11 {
						structs.InfoAddCommitLimit(t.Builder, n)
						continue
					}
					structs.InfoAddCommittedAS(t.Builder, n)
					continue
				}
				if v == 'D' {
					if nameLen == 5 {
						structs.InfoAddDirty(t.Builder, n)
						continue
					}
					if t.Val[10] == 'k' {
						structs.InfoAddDirectMap4K(t.Builder, n)
						continue
					}
					structs.InfoAddDirectMap2M(t.Builder, n)
					continue
				}
				if v == 'H' {
					if nameLen == 14 {
						if t.Val[10] == 'F' {
							structs.InfoAddHugePagesFree(t.Builder, n)
							continue
						}
						if t.Val[10] == 'R' {
							structs.InfoAddHugePagesRsvd(t.Builder, n)
							continue
						}
						structs.InfoAddHugePagesSurp(t.Builder, n)
					}
					if t.Val[1] == 'a' {
						structs.InfoAddHardwareCorrupted(t.Builder, n)
						continue
					}
					if t.Val[9] == 'i' {
						structs.InfoAddHugePagesSize(t.Builder, n)
						continue
					}
					structs.InfoAddHugePagesTotal(t.Builder, n)
					continue
				}
				if v == 'I' {
					if nameLen == 8 {
						structs.InfoAddInactive(t.Builder, n)
						continue
					}
					if t.Val[9] == 'a' {
						structs.InfoAddInactiveAnon(t.Builder, n)
						continue
					}
					structs.InfoAddInactiveFile(t.Builder, n)
				}
				if v == 'M' {
					v = t.Val[3]
					if nameLen < 8 {
						if v == 'p' {
							structs.InfoAddMapped(t.Builder, n)
							continue
						}
						if v == 'F' {
							structs.InfoAddMemFree(t.Builder, n)
							continue
						}
						structs.InfoAddMlocked(t.Builder, n)
						continue
					}
					if v == 'A' {
						structs.InfoAddMemAvailable(t.Builder, n)
						continue
					}
					structs.InfoAddMemTotal(t.Builder, n)
					continue
				}
				if v == 'S' {
					v = t.Val[1]
					if v == 'w' {
						if t.Val[4] == 'C' {
							structs.InfoAddSwapCached(t.Builder, n)
							continue
						}
						if t.Val[4] == 'F' {
							structs.InfoAddSwapFree(t.Builder, n)
							continue
						}
						structs.InfoAddSwapTotal(t.Builder, n)
						continue
					}
					if v == 'h' {
						structs.InfoAddShmem(t.Builder, n)
						continue
					}
					if v == 'l' {
						structs.InfoAddSlab(t.Builder, n)
						continue
					}
					if v == 'R' {
						structs.InfoAddSReclaimable(t.Builder, n)
						continue
					}
					structs.InfoAddSUnreclaim(t.Builder, n)
					continue
				}
				if v == 'V' {
					if t.Val[8] == 'C' {
						structs.InfoAddVmallocChunk(t.Builder, n)
						continue
					}
					if t.Val[8] == 'T' {
						structs.InfoAddVmallocTotal(t.Builder, n)
						continue
					}
					structs.InfoAddVmallocUsed(t.Builder, n)
					continue
				}
				if v == 'W' {
					if nameLen == 9 {
						structs.InfoAddWriteback(t.Builder, n)
						continue
					}
					structs.InfoAddWritebackTmp(t.Builder, n)
					continue
				}
				if v == 'B' {
					if nameLen == 6 {
						structs.InfoAddBounce(t.Builder, n)
						continue
					}
					structs.InfoAddBuffers(t.Builder, n)
					continue
				}
				if v == 'K' {
					structs.InfoAddKernelStack(t.Builder, n)
					continue
				}
				if v == 'N' {
					structs.InfoAddNFSUnstable(t.Builder, n)
					continue
				}
				if v == 'P' {
					structs.InfoAddPageTables(t.Builder, n)
				}
				structs.InfoAddUnevictable(t.Builder, n)
			}
			t.Builder.Finish(structs.InfoEnd(t.Builder))
			t.Data <- t.Profiler.Builder.Bytes[t.Builder.Head():]
		}
	}
}
393355
func (s *Server) Run() {
	go s.updater()
	go s.notifier()
	go s.manager()

	<-s.quit
}