// Poll reports whether there is input available in the stream.
429197
func (s *Stream) Poll() (bool, error) {
	poll := C.Pm_Poll(unsafe.Pointer(s.pmStream))
	if poll < 0 {
		return false, convertToError(C.PmError(poll))
	}
	return poll > 0, nil
}
1199061
func (h *websocketStreamHandler) run() {
	wg := sync.WaitGroup{}
	wg.Add(len(h.streamPairs))

	for _, pair := range h.streamPairs {
		p := pair
		go func() {
			defer wg.Done()
			h.portForward(p)
		}()
	}

	wg.Wait()
}
758552
func PollEvent() Event {
	ret := C.SDL_PollEvent(&cevent)
	if ret == 0 {
		return nil
	}
	return goEvent((*CEvent)(unsafe.Pointer(&cevent)))
}
1017799
func (p *RemoteMonitor) pollStdOutAndErr(
	cmd *exec.Cmd,
	contextID string,
) (err error) {

	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return err
	}

	stderr, err := cmd.StderrPipe()
	if err != nil {
		return err
	}

	// Stdout/err processing
	go processIOReader(stdout, contextID)
	go processIOReader(stderr, contextID)

	return nil
}
877275
func (s LoginSession) Vote(v Voter, vote Vote) error {
	req := &request{
		url: "https://www.reddit.com/api/vote",
		values: &url.Values{
			"id":  {v.voteID()},
			"dir": {string(vote)},
			"uh":  {s.modhash},
		},
		cookie:    s.cookie,
		useragent: s.useragent,
	}
	body, err := req.getResponse()
	if err != nil {
		return err
	}
	if body.String() != "{}" {
		return errors.New("failed to vote")
	}
	return nil
}
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
}
234763
func PollingInterval(i int) Option {
	return func(p *Plugin) error {
		p.PollingInterval = i
		return nil
	}
}
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
}
735825
func (fr *fileReader) pollChanges(ctx context.Context) {
	ticker := time.Tick(time.Duration(int64(time.Second) * fr.Cfg.UpdateIntervalSeconds))
	for {
		select {
		case <-ticker:
			if err := fr.startWalkingDisk(); err != nil {
				fr.log.Error("failed to search for dashboards", "error", err)
			}
		case <-ctx.Done():
			return
		}
	}
}
781848
func (c *Client) StopPoll(chatID string, messageID string, opts ...sendOption) (*Poll, error) {
	req := url.Values{}
	req.Set("chat_id", chatID)
	req.Set("message_id", messageID)
	for _, opt := range opts {
		opt(req)
	}
	poll := &Poll{}
	err := c.doRequest("stopPoll", req, poll)
	return poll, err
}
892991
func (poller *fdPoller) wake() error {
	buf := make([]byte, 1)
	n, errno := unix.Write(poller.pipe[1], buf)
	if n == -1 {
		if errno == unix.EAGAIN {
			// Buffer is full, poller will wake.
			return nil
		}
		return errno
	}
	return nil
}
1036754
func (post *ProjectPost) Votes() *[]Vote {
	ret := []ProjectPostVote{}
	Db().Model(ProjectPostVote{}).Where(&ProjectPostVote{Hpid: post.ID()}).Scan(&ret)
	var retVotes []Vote
	for _, v := range ret {
		vote := v
		retVotes = append(retVotes, Vote(&vote))
	}

	return &retVotes
}
1016498
func (s *Subscription) Poll(timeout time.Duration) (Event, error) {
	dl.Debugln("poll", timeout)

	s.timeout.Reset(timeout)

	select {
	case e, ok := <-s.events:
		if !ok {
			return e, ErrClosed
		}
		if runningTests {
			// Make the behavior stable when running tests to avoid randomly
			// varying test coverage. This ensures, in practice if not in
			// theory, that the timer fires and we take the true branch of
			// the next if.
			s.timeout.Reset(0)
			runtime.Gosched()
		}
		if !s.timeout.Stop() {
			// The timeout must be stopped and possibly drained to be ready
			// for reuse in the next call.
			<-s.timeout.C
		}
		return e, nil
	case <-s.timeout.C:
		return Event{}, ErrTimeout
	}
}
1358110
func (taskApi *TaskApi) PollResponse(response *api.CcaResponse, milliseconds time.Duration) ([]byte, error) {
	if strings.EqualFold(response.TaskStatus, SUCCESS) {
		return response.Data, nil
	} else if strings.EqualFold(response.TaskStatus, FAILED) {
		return nil, api.CcaErrorResponse(*response)
	}
	return taskApi.Poll(response.TaskId, milliseconds)
}
194537
func (c *loginCommand) Run(ctx *cmd.Context) error {
	errout := interact.NewErrWriter(ctx.Stdout)
	c.pollster = interact.New(ctx.Stdin, ctx.Stderr, errout)

	err := c.run(ctx)
	if err != nil && c.onRunError != nil {
		c.onRunError()
	}
	return err
}
288335
func (form FormImpl) Run(ws *websocket.Conn, app *App) error {
	msgs := []string{}
	for {
		_, bmsg, err := ws.ReadMessage()
		if err != nil {
			log.Println("Error on WS Receive", err)
			return ErrEOFWS
		}
		msg := string(bmsg)
		status.Status.ReceivedBytes += len(msg)
		if msg == endofmessage {
			break
		} else {
			msgs = append(msgs, msg)
		}
	}
	log.Printf("currentForm = %v msgs = %v\n", app.CurrentForm, msgs)
	if len(msgs) < 1 {
		log.Println("Protocol error len(msgs) < 1", msgs)
		return ErrProtocol
	}

	app.LastAccess = time.Now()
	f, present := form.trans[msgs[0]]
	if present {
		f(ws, app, msgs)
	} else {
		log.Println("Evt not found", msgs[0])
	}
	return nil
}
981407
func (v *Volume) Stream(samples [][2]float64) (n int, ok bool) {
	n, ok = v.Streamer.Stream(samples)
	gain := 0.0
	if !v.Silent {
		gain = math.Pow(v.Base, v.Volume)
	}
	for i := range samples[:n] {
		samples[i][0] *= gain
		samples[i][1] *= gain
	}
	return n, ok
}