// ForAll iterates thought all waiting proofs and passing the waiting proof
// in the given callback.
494555
func (s *WaitingProofStore) ForAll(cb func(*WaitingProof) error) error {
	return s.db.View(func(tx *bbolt.Tx) error {
		bucket := tx.Bucket(waitingProofsBucketKey)
		if bucket == nil {
			return ErrWaitingProofNotFound
		}

		// Iterate over objects buckets.
		return bucket.ForEach(func(k, v []byte) error {
			// Skip buckets fields.
			if v == nil {
				return nil
			}

			r := bytes.NewReader(v)
			proof := &WaitingProof{}
			if err := proof.Decode(r); err != nil {
				return err
			}

			return cb(proof)
		})
	})
}
532231
func (s *MappingsStore) All(ctx context.Context) ([]chronograf.Mapping, error) {
	var mappings []chronograf.Mapping
	err := s.each(ctx, func(m *chronograf.Mapping) {
		mappings = append(mappings, *m)
	})

	if err != nil {
		return nil, err
	}

	return mappings, nil
}
688173
func (ListAsyncJobs) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListAsyncJobsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListAsyncJobsResponse was expected, got %T", resp))
		return
	}

	for i := range items.AsyncJob {
		if !callback(&items.AsyncJob[i], nil) {
			break
		}
	}
}
763733
func (c *ExpireCache) Each(concurrent int, callBack func(key interface{}, value interface{}) error) []error {
	fanOut := NewFanOut(concurrent)
	keys := c.Keys()

	for _, key := range keys {
		fanOut.Run(func(key interface{}) error {
			c.mutex.Lock()
			record, ok := c.cache[key]
			c.mutex.Unlock()
			if !ok {
				return errors.Errorf("Each() - key '%+v' disapeared "+
					"from cache during iteration", key)
			}

			err := callBack(key, record.Value)
			if err != nil {
				return err
			}

			c.mutex.Lock()
			if record.ExpireAt.Before(time.Now().UTC()) {
				delete(c.cache, key)
			}
			c.mutex.Unlock()
			return nil
		}, key)
	}

	// Wait for all the routines to complete
	errs := fanOut.Wait()
	if errs != nil {
		return errs
	}

	return nil
}
1063512
func (ListSnapshots) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListSnapshotsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListSnapshotsResponse was expected, got %T", resp))
		return
	}

	for i := range items.Snapshot {
		if !callback(&items.Snapshot[i], nil) {
			break
		}
	}
}
395827
func (node *TrieNode) ForEach(callback func(*TrieNode)) {
	callback(node)
	for _, child := range node.children {
		child.ForEach(callback)
	}
}
203077
func (ListTemplates) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListTemplatesResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListTemplatesResponse was expected, got %T", resp))
		return
	}

	for i := range items.Template {
		if !callback(&items.Template[i], nil) {
			break
		}
	}
}
1228316
func (t *IfNode) All() []Node {
	return []Node{t.Cond, t.Body, t.Else}
}
1350014
func All(asyncs ...Async) Async {
	return &asyncImpl{
		cancel: func() {
			for _, a := range asyncs {
				a.Cancel()
			}
		},
		promise: Promise(func() error {
			errs := make([]error, 0)
			for _, a := range asyncs {
				err := <-a.Result()
				if err != nil {
					errs = append(errs, err)
				}
			}
			if len(errs) > 0 {
				return &GroupError{Errs: errs}
			}
			return nil
		}),
	}
}
781861
func For(msg string, timeout, interval time.Duration, f func() (bool, error)) error {
	log.Infof("Wait for %s [timeout: %s, interval: %s]", msg, timeout, interval)

	var lastErr string
	timeUp := time.After(timeout)
	for {
		select {
		case <-timeUp:
			return fmt.Errorf("time limit exceeded: last error: %s", lastErr)
		default:
		}

		stop, err := f()
		if stop {
			return nil
		}
		if err != nil {
			lastErr = err.Error()
		}

		time.Sleep(interval)
	}
}
1115589
func All(f, xs interface{}) bool {
	chk := ty.Check(
		new(func(func(ty.A) bool, []ty.A) bool),
		f, xs)
	vf, vxs := chk.Args[0], chk.Args[1]

	xsLen := vxs.Len()
	for i := 0; i < xsLen; i++ {
		if !call1(vf, vxs.Index(i)).Interface().(bool) {
			return false
		}
	}
	return true
}
781281
func (wg *WaitGroup) WaitFor(timeout time.Duration) bool {
	if timeout == time.Duration(0) {
		wg.Wait()
		return true // ### return, always true ###
	}

	start := time.Now()
	spin := NewSpinner(SpinPriorityHigh)
	for wg.Active() {
		if time.Since(start) > timeout {
			return false // ### return, timed out ###
		}
		spin.Yield()
	}
	return true
}
405770
func (self *Collection) All() []Model {
	if self.coll.Demand() == nil {
		return nil
	}
	curr := self.coll.Demand().(EqList)
	result := make([]Model, len(curr))
	for i, c := range curr {
		result[i] = c
	}
	return result
}
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
		}
	}
}
513416
func (s *UpdateByQueryService) WaitForCompletion(waitForCompletion bool) *UpdateByQueryService {
	s.waitForCompletion = &waitForCompletion
	return s
}
558327
func (c *memoryStore) ApplyAll(apply StoreReducer) {
	wg := new(sync.WaitGroup)
	for _, cont := range c.all() {
		wg.Add(1)
		go func(sandbox *Sandbox) {
			apply(sandbox)
			wg.Done()
		}(cont)
	}

	wg.Wait()
}
573695
func (s *TasksGetTaskService) WaitForCompletion(waitForCompletion bool) *TasksGetTaskService {
	s.waitForCompletion = &waitForCompletion
	return s
}