// Every triggers f every t time.Duration until the end of days, or when a Stop()
// is called on the Ticker that is returned by the Every function.
// It does not wait for the previous execution of f to finish before
// it fires the next f.
182703
func Every(t time.Duration, f func()) *time.Ticker {
	ticker := time.NewTicker(t)

	go func() {
		for {
			select {
			case <-ticker.C:
				f()
			}
		}
	}()

	return ticker
}
185602
func StopAll(stopGrace time.Duration, startStoppers ...StartStopper) <-chan stop.Signal {
	stoppers := make([]stop.Stopper, len(startStoppers))
	for i, ss := range startStoppers {
		stoppers[i] = ss.(stop.Stopper)
	}
	return stop.All(stopGrace, stoppers...)
}
259605
func (tm *Timer) Stop() {
	tm.mu.Lock()
	defer tm.mu.Unlock()
	if tm.running {
		tm.msg <- timerStop
		tm.running = false
	}
}
731149
func AfterFunc(d time.Duration, f func()) Timer {
	return provider.AfterFunc(d, f)
}
1169293
func (r *SearchResult) Each(typ reflect.Type) []interface{} {
	if r.Hits == nil || r.Hits.Hits == nil || len(r.Hits.Hits) == 0 {
		return nil
	}
	slice := make([]interface{}, 0)
	for _, hit := range r.Hits.Hits {
		v := reflect.New(typ).Elem()
		if err := json.Unmarshal(*hit.Source, v.Addr().Interface()); err == nil {
			slice = append(slice, v.Interface())
		}
	}
	return slice
}
107623
func (ks *JavaServerSelector) Each(f func(net.Addr) error) error {
	ks.lock.RLock()
	defer ks.lock.RUnlock()
	for _, a := range ks.addrs {
		if err := f(a); nil != err {
			return err
		}
	}
	return nil
}
682599
func (ListNetworks) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListNetworksResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListNetworksResponse was expected, got %T", resp))
		return
	}

	for i := range items.Network {
		if !callback(&items.Network[i], nil) {
			break
		}
	}
}
409588
func (o *Once) Stop(f func() error) error {
	if o.state.CAS(int32(Idle), int32(Stopped)) {
		close(o.startCh)
		close(o.stoppingCh)
		close(o.stopCh)
		return nil
	}

	<-o.startCh

	if o.state.CAS(int32(Running), int32(Stopping)) {
		close(o.stoppingCh)

		var err error
		if f != nil {
			err = f()
		}

		if err != nil {
			o.setError(err)
			o.state.Store(int32(Errored))
		} else {
			o.state.Store(int32(Stopped))
		}
		close(o.stopCh)
		return err
	}

	<-o.stopCh
	return o.loadError()
}
934982
func (exp *FuncExpr) All() []Node {
	res := make([]Node, len(exp.Args))
	for i, n := range exp.Args {
		res[i] = n
	}
	return res
}
1145990
func (ListSSHKeyPairs) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListSSHKeyPairsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListSSHKeyPairsResponse was expected, got %T", resp))
		return
	}

	for i := range items.SSHKeyPair {
		if !callback(&items.SSHKeyPair[i], nil) {
			break
		}
	}
}
1128291
func (r *PrefixedRegistry) Each(fn func(string, interface{})) {
	wrappedFn := func(prefix string) func(string, interface{}) {
		return func(name string, iface interface{}) {
			if strings.HasPrefix(name, prefix) {
				fn(name, iface)
			} else {
				return
			}
		}
	}

	baseRegistry, prefix := findPrefix(r, "")
	baseRegistry.Each(wrappedFn(prefix))
}
103449
func All(f func()) (captured *Result) {
	var oldStdout, oldStderr *os.File

	// Setup the thing.
	captured = &Result{}
	outFile, errFile := setupFiles()

	// It recovers from panics and it tears down all the temporary stuff that
	// has been created inside this function.
	defer func() {
		if r := recover(); r != nil {
			captured.Error = fmt.Errorf("Panic: %v", r)
		}
		cleanup(outFile, errFile)
		os.Stdout, os.Stderr = oldStdout, oldStderr
	}()

	// Exchange the output channels and call the function.
	oldStdout, oldStderr = os.Stdout, os.Stderr
	os.Stdout, os.Stderr = outFile, errFile
	f()
	captured.Stdout, _ = ioutil.ReadFile(outFile.Name())
	captured.Stderr, _ = ioutil.ReadFile(errFile.Name())
	return captured
}
880990
func (ListTags) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListTagsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListTagsResponse was expected, got %T", resp))
		return
	}

	for i := range items.Tag {
		if !callback(&items.Tag[i], nil) {
			break
		}
	}
}
927872
func (ListOSCategories) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListOSCategoriesResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListOSCategoriesResponse was expected, got %T", resp))
		return
	}

	for i := range items.OSCategory {
		if !callback(&items.OSCategory[i], nil) {
			break
		}
	}
}
928500
func (p *Pool) Each(f func(*Bytes)) {
	l := len(p.list)
	t := make([]*Bytes, l)
	defer func() {
		for i := 0; i < len(t); i++ {
			t[i].Release()
		}
	}()
	for i := 0; i < l; i++ {
		b := <-p.list
		t[i] = b
		f(b)
	}
}
855875
func (tt *TimerToken) Stop() time.Duration {
	duration := time.Since(tt.Start)
	tt.MetricSystem.Histogram(tt.Name, float64(duration.Nanoseconds()))
	return duration
}
186832
func (ListZones) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListZonesResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListZonesResponse was expected, got %T", resp))
		return
	}

	for i := range items.Zone {
		if !callback(&items.Zone[i], nil) {
			break
		}
	}
}