// Poll sieves updates through middleware filter.
489417
func (p *MiddlewarePoller) Poll(b *Bot, dest chan Update, stop chan struct{}) {
	cap := 1
	if p.Capacity > 1 {
		cap = p.Capacity
	}

	middle := make(chan Update, cap)
	stopPoller := make(chan struct{})

	go p.Poller.Poll(b, middle, stopPoller)

	for {
		select {
		// call to stop
		case <-stop:
			stopPoller <- struct{}{}

		// poller is done
		case <-stopPoller:
			close(stop)
			return

		case upd := <-middle:
			if p.Filter(&upd) {
				dest <- upd
			}
		}
	}
}
443617
func ServicePoll(config *poll.Settings) {
	// Override the default pollSettings for `service` resource here ...
	config.Timeout = 30 * time.Second
	config.Delay = 100 * time.Millisecond
	if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
		config.Timeout = 90 * time.Second
	}
}
1296008
func (sm *ServiceMap) filter(other ServiceMap) {
	for svcPortName := range *sm {
		// skip the delete for Update event.
		if _, ok := other[svcPortName]; ok {
			delete(*sm, svcPortName)
		}
	}
}
474885
func (r *SearchRequest) PostFilter(filter Query) *SearchRequest {
	r.searchSource = r.searchSource.PostFilter(filter)
	return r
}
1114381
func NewPostVote() echo.HandlerFunc {

	// swagger:route POST /me/posts/{pid}/votes me post vote NewMePostVote
	//
	// Adds a new vote on the current post
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_messages:write
	//
	//	Responses:
	//		default: MePostsPidVotes

	return func(c echo.Context) error {
		return user.NewPostVote()(c)
	}
}
1055510
func (h *connectionHeap) Poll(hint byte) (res *Connection) {
	idx := int(hint)

	end := idx + len(h.heaps)
	for i := idx; i < end; i++ {
		if conn := h.heaps[i%len(h.heaps)].Poll(); conn != nil {
			return conn
		}
	}
	return nil
}
903236
func (o *OAuthSession) Vote(v Voter, dir Vote) error {
	// Build form for POST request.
	form := url.Values{
		"id":  {v.voteID()},
		"dir": {string(dir)},
	}
	var vo interface{}

	err := o.postBody("https://oauth.reddit.com/api/vote", form, vo)
	if err != nil {
		return err
	}
	return nil
}
485472
func (tp *TransferPoller) Poll() error {
	tp.syncTimer.Pause()
	err := tp.pollTransfers()
	tp.syncTimer.Resume()
	return err
}
1158761
func (s *NeutrinoClient) pollCFilter(hash *chainhash.Hash) (*gcs.Filter, error) {
	var (
		filter *gcs.Filter
		err    error
		count  int
	)

	const maxFilterRetries = 50
	for count < maxFilterRetries {
		if count > 0 {
			time.Sleep(100 * time.Millisecond)
		}

		filter, err = s.CS.GetCFilter(*hash, wire.GCSFilterRegular)
		if err != nil {
			count++
			continue
		}

		return filter, nil
	}

	return nil, err
}
679970
func (p *Poller) Update(id int, events State) (previous State, err error) {
	if id >= 0 && id < len(p.items) {
		previous = State(p.items[id].events)
		p.items[id].events = C.short(events)
		return previous, nil
	}
	return 0, ErrorNoSocket
}
1213194
func (m *machineTracker) WantsVote() bool {
	m.mu.Lock()
	defer m.mu.Unlock()
	return m.wantsVote
}
1300390
func (p *Peer) sendVoteRequest(req *RequestVoteRequest, c chan *RequestVoteResponse) {
	debugln("peer.vote: ", p.server.Name(), "->", p.Name)
	req.peer = p
	if resp := p.server.Transporter().SendVoteRequest(p.server, p, req); resp != nil {
		debugln("peer.vote.recv: ", p.server.Name(), "<-", p.Name)
		p.setLastActivity(time.Now())
		resp.peer = p
		c <- resp
	} else {
		debugln("peer.vote.failed: ", p.server.Name(), "<-", p.Name)
	}
}
634043
func (taskApi *TaskApi) Poll(id string, milliseconds time.Duration) ([]byte, error) {
	ticker := time.NewTicker(time.Millisecond * milliseconds)
	task, err := taskApi.Get(id)
	if err != nil {
		return nil, err
	}
	done := task.Completed()
	for !done {
		<-ticker.C
		task, err = taskApi.Get(id)
		if err != nil {
			return nil, err
		}
		done = task.Completed()
	}
	if task.Failed() {
		return nil, FailedTask(*task)
	}
	return task.Result, nil
}
456746
func newRequestVoteResponse(term uint64, voteGranted bool) *RequestVoteResponse {
	return &RequestVoteResponse{
		Term:        term,
		VoteGranted: voteGranted,
	}
}
315363
func PollEvents() <-chan Event {
	ch := make(chan Event)
	go func() {
		for {
			ch <- convertTermboxEvent(tb.PollEvent())
		}
	}()
	return ch
}
1112211
func (req *SrvReq) Flush() {
	req.Lock()
	req.status |= reqFlush
	req.Unlock()
	req.Respond()
}
856268
func (p *ActivityTaskPoller) Poll() (*swf.PollForActivityTaskOutput, error) {
	resp, err := p.client.PollForActivityTask(&swf.PollForActivityTaskInput{
		Domain:   aws.String(p.Domain),
		Identity: aws.String(p.Identity),
		TaskList: &swf.TaskList{Name: aws.String(p.TaskList)},
	})
	if err != nil {
		Log.Printf("component=ActivityTaskPoller at=error error=%q", err.Error())
		return nil, errors.Trace(err)
	}
	if resp.TaskToken != nil {
		Log.Printf("component=ActivityTaskPoller at=activity-task-received activity=%s", LS(resp.ActivityType.Name))
		return resp, nil
	}
	Log.Println("component=ActivityTaskPoller at=activity-task-empty-response")
	return nil, nil
}