// poll polls the synchronisation server for notifications, then dispatches
// them for processing.
346093
func (sc *syncClient) poll(sid SyncSessionID) {
	for {
		var sn SyncNotes
		poll := sc.client.Go("SeesawSync.Poll", sid, &sn, nil)
		select {
		case <-poll.Done:
			if poll.Error != nil {
				log.Errorf("Synchronisation polling failed: %v", poll.Error)
				return
			}
			for _, note := range sn.Notes {
				sc.dispatch(&note)
			}

		case <-sc.quit:
			sc.stopped <- true
			return

		case <-time.After(syncPollTimeout):
			log.Warningf("Synchronisation polling timed out after %s", syncPollTimeout)
			return
		}
	}
}
183928
func (c *Collector) pollHost() {
	now := time.Now().UTC()
	c.timestamp = now.Unix()

	// Fetch node-level metrics for all DC/OS roles
	c.log.Debugf("Fetching node-level metrics from DC/OS host %s", c.nodeInfo.Hostname)
	nm, err := getNodeMetrics()
	if err != nil {
		c.log.Errorf("Failed to get node-level metrics. %s", err)
	} else {
		c.nodeMetrics = nm
	}

	c.log.Infof("Finished polling DC/OS host %s, took %f seconds.", c.nodeInfo.Hostname, time.Since(now).Seconds())
}
107415
func (p *remoteRelationPoller) pollLoop() error {
	logger.Debugf("polling for relation %v on %v to be ready", p.relationTag, p.applicationTag)
	for {
		select {
		case <-p.catacomb.Dying():
			return p.catacomb.ErrDying()
		case <-p.fw.pollClock.After(3 * time.Second):
			// Relation is exported with the consuming model UUID.
			relToken, err := p.fw.remoteRelationsApi.GetToken(p.relationTag)
			if err != nil {
				continue
			}
			logger.Debugf("token %v for relation id: %v in model %v", relToken, p.relationTag.Id(), p.fw.modelUUID)

			// Application is exported with the offering model UUID.
			appToken, err := p.fw.remoteRelationsApi.GetToken(p.applicationTag)
			if err != nil {
				continue
			}
			logger.Debugf("token %v for application id: %v", appToken, p.applicationTag.Id())

			// relation and application are ready.
			relationInfo := remoteRelationInfo{
				relationToken:    relToken,
				applicationToken: appToken,
			}
			select {
			case <-p.catacomb.Dying():
				return p.catacomb.ErrDying()
			case p.relationReady <- relationInfo:
			}
			return nil
		}
	}
}
1182640
func (cli *OpsGenieHeartbeatClient) Ping(req heartbeat.PingHeartbeatRequest) (*AsyncRequestResponse, error) {
	return cli.sendAsyncPostRequest(&req)
}
1123815
func (c *Client) PollForActivityTask(request PollForActivityTaskRequest) (*PollForActivityTaskResponse, error) {
	resp := &PollForActivityTaskResponse{}
	err := c.swfReqWithResponse("PollForActivityTask", request, resp)
	return resp, err
}
151952
func (_m *MessageReceiver) Consensus(req *orderer.ConsensusRequest, sender uint64) error {
	ret := _m.Called(req, sender)

	var r0 error
	if rf, ok := ret.Get(0).(func(*orderer.ConsensusRequest, uint64) error); ok {
		r0 = rf(req, sender)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
693989
func (d *Document) Poll(ctx context.Context, pause time.Duration) APIResponse {
	// store upload duration. Will be overwritten otherwise
	uploadDuration := d.Timing.Upload

	start := time.Now()
	defer func() { d.Timing.Processing = time.Since(start) }()

	type CombinedResponse struct {
		doc  *Document
		resp APIResponse
	}

	docProgress := make(chan CombinedResponse, 1)

	go func(ctx context.Context) {
		for {
			select {
			case <-ctx.Done():
				return
			default:
				doc, getResponse := d.client.Get(ctx, d.Links.Document, d.Owner)
				docResponse := CombinedResponse{doc, getResponse}

				// we need to keep polling until we hit an error or finish processing
				if getResponse.Error != nil || (doc.Progress == "COMPLETED" || doc.Progress == "ERROR") {
					docProgress <- docResponse
					return
				}

				// be a (potentially) good neighbour
				time.Sleep(pause)
			}
		}
	}(ctx)

	select {
	case answer := <-docProgress:
		if answer.doc == nil || answer.resp.Error != nil {
			return answer.resp
		}

		// replace ourself with the polled document
		*d = *answer.doc

		// restore upload duration
		d.Timing.Upload = uploadDuration

		return apiResponse("polling completed", d.ID, answer.resp.HttpResponse, nil)
	case <-ctx.Done():
		return apiResponse("polling aborted", d.ID, nil, ctx.Err())
	}
}
538984
func PollEvent() Event {
	// Constant governing macOS specific behavior. See https://github.com/nsf/termbox-go/issues/132
	// This is an arbitrary delay which hopefully will be enough time for any lagging
	// partial escape sequences to come through.
	const esc_wait_delay = 100 * time.Millisecond

	var event Event
	var esc_wait_timer *time.Timer
	var esc_timeout <-chan time.Time

	// try to extract event from input buffer, return on success
	event.Type = EventKey
	status := extract_event(inbuf, &event, true)
	if event.N != 0 {
		copy(inbuf, inbuf[event.N:])
		inbuf = inbuf[:len(inbuf)-event.N]
	}
	if status == event_extracted {
		return event
	} else if status == esc_wait {
		esc_wait_timer = time.NewTimer(esc_wait_delay)
		esc_timeout = esc_wait_timer.C
	}

	for {
		select {
		case ev := <-input_comm:
			if esc_wait_timer != nil {
				if !esc_wait_timer.Stop() {
					<-esc_wait_timer.C
				}
				esc_wait_timer = nil
			}

			if ev.err != nil {
				return Event{Type: EventError, Err: ev.err}
			}

			inbuf = append(inbuf, ev.data...)
			input_comm <- ev
			status := extract_event(inbuf, &event, true)
			if event.N != 0 {
				copy(inbuf, inbuf[event.N:])
				inbuf = inbuf[:len(inbuf)-event.N]
			}
			if status == event_extracted {
				return event
			} else if status == esc_wait {
				esc_wait_timer = time.NewTimer(esc_wait_delay)
				esc_timeout = esc_wait_timer.C
			}
		case <-esc_timeout:
			esc_wait_timer = nil

			status := extract_event(inbuf, &event, false)
			if event.N != 0 {
				copy(inbuf, inbuf[event.N:])
				inbuf = inbuf[:len(inbuf)-event.N]
			}
			if status == event_extracted {
				return event
			}
		case <-interrupt_comm:
			event.Type = EventInterrupt
			return event

		case <-sigwinch:
			event.Type = EventResize
			event.Width, event.Height = get_term_size(out.Fd())
			return event
		}
	}
}
1224819
func (bstar *Bstar) voter_ready(socket *zmq.Socket) error {
	//  If server can accept input now, call appl handler
	bstar.event = client_REQUEST
	err := bstar.execute_fsm()
	if err == nil {
		bstar.voter_fn(socket)
	} else {
		//  Destroy waiting message, no-one to read it
		socket.RecvMessage(0)
	}
	return nil
}
127040
func (provider *DashboardProvisionerImpl) PollChanges(ctx context.Context) {
	for _, reader := range provider.fileReaders {
		go reader.pollChanges(ctx)
	}
}
160243
func pollRxQueue(memif *Memif, queueID uint8) {
	defer memif.wg.Done()

	log.WithFields(logger.Fields{
		"ifName":   memif.IfName,
		"queue-ID": queueID,
	}).Debug("Started queue interrupt polling.")

	var qfd C.int
	errCode := C.memif_get_queue_efd(memif.cHandle, C.uint16_t(queueID), &qfd)
	err := getMemifError(int(errCode))
	if err != nil {
		log.WithField("err", err).Error("memif_get_queue_efd() failed")
		return
	}

	// Create epoll file descriptor.
	var event [1]syscall.EpollEvent
	epFd, err := syscall.EpollCreate1(0)
	if err != nil {
		log.WithField("err", err).Error("epoll_create1() failed")
		return
	}
	defer syscall.Close(epFd)

	// Add Rx queue interrupt file descriptor.
	event[0].Events = syscall.EPOLLIN
	event[0].Fd = int32(qfd)
	if err = syscall.EpollCtl(epFd, syscall.EPOLL_CTL_ADD, int(qfd), &event[0]); err != nil {
		log.WithField("err", err).Error("epoll_ctl() failed")
		return
	}

	// Add file descriptor used to stop this go routine.
	event[0].Events = syscall.EPOLLIN
	event[0].Fd = int32(memif.stopQPollFd)
	if err = syscall.EpollCtl(epFd, syscall.EPOLL_CTL_ADD, memif.stopQPollFd, &event[0]); err != nil {
		log.WithField("err", err).Error("epoll_ctl() failed")
		return
	}

	// Poll for interrupts.
	for {
		_, err := syscall.EpollWait(epFd, event[:], -1)
		if err != nil {
			log.WithField("err", err).Error("epoll_wait() failed")
			return
		}

		// Handle Rx Interrupt.
		if event[0].Fd == int32(qfd) {
			// Consume the interrupt event.
			buf := make([]byte, 8)
			_, err = syscall.Read(int(qfd), buf[:])
			if err != nil {
				log.WithField("err", err).Warn("read() failed")
			}

			// Send signal to memif-global interrupt channel.
			select {
			case memif.intCh <- queueID:
				break
			default:
				break
			}

			// Send signal to queue-specific interrupt channel.
			select {
			case memif.queueIntCh[queueID] <- struct{}{}:
				break
			default:
				break
			}
		}

		// Stop the go routine if requested.
		if event[0].Fd == int32(memif.stopQPollFd) {
			log.WithFields(logger.Fields{
				"ifName":   memif.IfName,
				"queue-ID": queueID,
			}).Debug("Stopped queue interrupt polling.")
			return
		}
	}
}
758552
func PollEvent() Event {
	ret := C.SDL_PollEvent(&cevent)
	if ret == 0 {
		return nil
	}
	return goEvent((*CEvent)(unsafe.Pointer(&cevent)))
}
234763
func PollingInterval(i int) Option {
	return func(p *Plugin) error {
		p.PollingInterval = i
		return nil
	}
}
698646
func NewServer(version, url string, period time.Duration) *Server {
	s := &Server{version: version, url: url, period: period}
	go s.poll()
	return s
}
838111
func (agent *Agent) poll(ctx context.Context) error {
	// Metadata tells us which Machine Provider instance to talk to
	// and how to authenticate.
	for {
		logging.Infof(ctx, "Polling.")
		instruction, err := agent.mp.poll(ctx, agent.hostname, "GCE")
		if err != nil {
			// Log error but don't return. Keep polling.
			logging.Errorf(ctx, "%s", err.Error())
		} else {
			if err = agent.handle(ctx, instruction); err != nil {
				return err
			}
		}
		tsmon.Flush(ctx)
		time.Sleep(time.Minute)
	}
}
656046
func (c *asyncClient) Ping() (stat FutureBool, err Error) {
	resp, err := c.conn.QueueRequest(&PING, [][]byte{})
	if err == nil {
		stat = resp.future.(FutureBool)
	}

	return
}
327492
func (t *Termbox) PollEvent(ctx context.Context) chan termbox.Event {
	// XXX termbox.PollEvent() can get stuck on unexpected signal
	// handling cases. We still would like to wait until the user
	// (termbox) has some event for us to process, but we don't
	// want to allow termbox to control/block our input loop.
	//
	// Solution: put termbox polling in a separate goroutine,
	// and we just watch for a channel. The loop can now
	// safely be implemented in terms of select {} which is
	// safe from being stuck.
	evCh := make(chan termbox.Event)

	go func() {
		// keep listening to suspend requests here
		for {
			select {
			case <-ctx.Done():
				return
			case <-t.suspendCh:
				if pdebug.Enabled {
					pdebug.Printf("poll event suspended!")
				}
				t.Close()
			}
		}
	}()

	go func() {
		defer func() { recover() }()
		defer func() { close(evCh) }()

		for {
			ev := termbox.PollEvent()
			if ev.Type != termbox.EventInterrupt {
				evCh <- ev
				continue
			}

			select {
			case <-ctx.Done():
				return
			case replyCh := <-t.resumeCh:
				t.Init()
				close(replyCh)
			}
		}
	}()
	return evCh

}