// RenderEvents reads every event sent on the given channel and renders it.
// The channel can be closed by the caller at any time to stop rendering.
495621
func (r *Renderer) RenderEvents(eventCh <-chan *TaskEvent) {
	for event := range eventCh {
		r.RenderEvent(event)
	}
}
375789
func (sa *StubAPIClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
	sa.called()
	return sa.EventsFn(ctx, options)
}
1101297
func ConvertEvents(ctx context.Context, appl application.Application, request *http.Request, eventList []event.Event, wiID uuid.UUID) ([]*app.Event, error) {
	var ls = []*app.Event{}
	for _, i := range eventList {
		converted, err := ConvertEvent(ctx, appl, request, i, wiID)
		if err != nil {
			return nil, errs.Wrapf(err, "failed to convert event: %+v", i)
		}
		ls = append(ls, converted)
	}
	return ls, nil
}
1218097
func (e ActualLRPEventCalculator) EmitEvents(beforeSet, afterSet []*models.ActualLRP) {
	events := []models.Event{}

	beforeGroup := models.ResolveActualLRPGroup(beforeSet)
	afterGroup := models.ResolveActualLRPGroup(removeNilLRPs(afterSet))

	for _, ev := range generateLRPGroupEvents(beforeGroup, afterGroup) {
		e.ActualLRPGroupHub.Emit(ev)
	}

	// stretch the two slices to be of equal size.  make sure we do this after
	// emitting the group events, otherwise ResolveActualLRPGroup will panic if
	// it encounters nil lrps.
	stretchSlice(&beforeSet, &afterSet)

	for i := range afterSet {
		events = append(events, generateLRPInstanceEvents(beforeSet[i], afterSet[i])...)
	}

	sort.Slice(events, func(i, j int) bool {
		return EventScore(events[i]) > EventScore(events[j])
	})

	for _, ev := range events {
		e.ActualLRPInstanceHub.Emit(ev)
	}
}
526868
func RegisterEvents(numEvents int) uint32 {
	return uint32(C.SDL_RegisterEvents(C.int(numEvents)))
}
1225101
func Render(doc []byte) []byte {
	renderer := NewRoffRenderer()

	return blackfriday.Run(doc,
		[]blackfriday.Option{blackfriday.WithRenderer(renderer),
			blackfriday.WithExtensions(renderer.GetExtensions())}...)
}
696122
func (be *BlockExecution) StreamEvents() StreamEvents {
	var ses StreamEvents
	ses = append(ses, &StreamEvent{
		BeginBlock: &BeginBlock{
			Height: be.Height,
			Header: be.Header,
		},
	})
	for _, txe := range be.TxExecutions {
		ses = append(ses, txe.StreamEvents()...)
	}
	return append(ses, &StreamEvent{
		EndBlock: &EndBlock{
			Height: be.Height,
		},
	})
}
94275
func (t *Template) RenderString(context ...interface{}) (string, error) {
	b := &bytes.Buffer{}
	err := t.Render(b, context...)
	return b.String(), err
}
180896
func AsyncEvents(e EventStream) EventStream {
	s := &asyncEventStream{
		e:      e,
		events: make(chan Event, 100),
	}
	go s.start()
	return s
}
1293602
func (s *ClientConfigChangerSink) AddEvents(ctx context.Context, events []*event.Event) error {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.Destination.AddEvents(ctx, events)
}
1247104
func (s *SetCognitoEventsInput) SetEvents(v map[string]*string) *SetCognitoEventsInput {
	s.Events = v
	return s
}
838926
func (_m *APIClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
	ret := _m.Called(ctx, options)

	var r0 <-chan events.Message
	if rf, ok := ret.Get(0).(func(context.Context, types.EventsOptions) <-chan events.Message); ok {
		r0 = rf(ctx, options)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(<-chan events.Message)
		}
	}

	var r1 <-chan error
	if rf, ok := ret.Get(1).(func(context.Context, types.EventsOptions) <-chan error); ok {
		r1 = rf(ctx, options)
	} else {
		if ret.Get(1) != nil {
			r1 = ret.Get(1).(<-chan error)
		}
	}

	return r0, r1
}
606484
func (h *eventHub) processEvents() {
	for {
		select {
		case connection := <-h.register:
			h.connections.Register(connection)
		case connection := <-h.unregister:
			h.connections.Unregister(connection)
		case msg := <-h.broadcast:
			h.connections.Broadcast(msg)
		}
	}
}
757655
func sendEvents(target event.Target, eventKeyCh <-chan string, doneCh <-chan struct{}) {
	retryTimer := time.NewTimer(retryInterval)
	defer retryTimer.Stop()

	send := func(eventKey string) bool {
		for {
			err := target.Send(eventKey)
			if err == nil {
				break
			}

			if err != errNotConnected {
				panic(fmt.Errorf("target.Send() failed with '%v'", err))
			}

			retryTimer.Reset(retryInterval)
			select {
			case <-retryTimer.C:
			case <-doneCh:
				return false
			}
		}
		return true
	}

	for {
		select {
		case eventKey, ok := <-eventKeyCh:
			if !ok {
				// closed channel.
				return
			}

			if !send(eventKey) {
				return
			}
		case <-doneCh:
			return
		}
	}
}
682421
func (ctx *Context) Render(bytes []byte) {
	//debug
	//fmt.Println("response msg = ", string(bytes))
	ctx.Writer.WriteHeader(200)
	_, err := ctx.Writer.Write(bytes)
	if err != nil {
		panic(err)
	}
}
1184510
func (m *MockInterface) Events() v1beta16.EventsV1beta1Interface {
	ret := m.ctrl.Call(m, "Events")
	ret0, _ := ret[0].(v1beta16.EventsV1beta1Interface)
	return ret0
}
693833
func (i *instanceManager) handleEvents() {
	eventsCh, cancel, err := i.dispenseTaskEventsCh()
	if err != nil {
		i.logger.Error("failed to dispense driver", "error", err)
	}

	var backoff time.Duration
	var retry int
	for {
		if backoff > 0 {
			select {
			case <-time.After(backoff):
			case <-i.ctx.Done():
				cancel()
				return
			}
		}

		select {
		case <-i.ctx.Done():
			cancel()
			return
		case ev, ok := <-eventsCh:
			if ok {
				i.handleEvent(ev)
				continue
			}

			// if the channel is closed attempt to open a new one
			newEventsChan, newCancel, err := i.dispenseTaskEventsCh()
			if err != nil {
				i.logger.Warn("failed to receive task events, retrying", "error", err, "retry", retry)

				// Calculate the new backoff
				backoff = (1 << (2 * uint64(retry))) * driverFPBackoffBaseline
				if backoff > driverFPBackoffLimit {
					backoff = driverFPBackoffLimit
				}
				retry++
				continue
			}
			cancel()
			eventsCh = newEventsChan
			cancel = newCancel

			// Reset backoff
			backoff = 0
			retry = 0
		}
	}
}