int mspoll(dev_t dev, int events, struct lwp *l) { struct ms_softc *ms; ms = device_lookup_private(&ms_cd, minor(dev)); return ev_poll(&ms->ms_events, events, l); }
int mspoll(dev_t dev, int events, struct lwp *l) { struct ms_softc *ms; ms = &ms_softc[minor(dev)]; return(ev_poll(&ms->ms_events, events, l)); }
int kbdpoll(dev_t dev, int events, struct lwp *l) { struct kbd_softc *k; k = device_lookup_private(&kbd_cd, minor(dev)); return ev_poll(&k->k_events, events, l); }
int mspoll(dev_t dev, int events, struct lwp *l) { struct ms_port *ms; ms = MS_DEV2MSPORT(dev); return(ev_poll(&ms->ms_events, events, l)); }
void *worker_run(void* userdata) { int num_events, flush_outbox; worker_t* self = userdata; ev_event_t *event; conn_t *conn; ev_init(&self->loop); ev_watch(&self->loop, self->conn_queue[0], EV_READABLE, self); ev_watch(&self->loop, self->msg_queue[0], EV_READABLE, NULL); while(self->running) { num_events = ev_poll(&self->loop); flush_outbox = 0; if (num_events == -1) continue; while (--num_events >= 0) { event = self->loop.fired[num_events]; if (!event->fired) continue; if (!event->userdata) { if (event->fired & EV_READABLE) worker_flush_inbox(self); else flush_outbox = 1; continue; } else if (event->userdata == self) { worker_accept(self); continue; } conn = event->userdata; if (event->fired & EV_READABLE) if (conn_read(conn) == -1) continue; if (event->fired & EV_WRITEABLE) if (conn_write(conn) == -1) continue; } if (flush_outbox) worker_flush_outbox(self); } worker_cleanup(self); return NULL; }
void doevents(void) { event_t ev; int st; ev_poll(); while (ev_getevent(&ev)) { if (ev.type != EV_PRESS && ev.type != EV_RELEASE) continue; st = (ev.type != EV_RELEASE); pad_set(ev.code, st); } }
/* * @func ev_run() * @desc start event loop */ void ev_run(void) { while (run) { ev_poll(); struct timeval t; gettimeofday(&t, NULL); if ((1000000 * (t.tv_sec - tv.tv_sec) + t.tv_usec - tv.tv_usec) > 1000000) { tv = t; (twcb)(); } } }
void doevents() { event_t ev; int st; //ev_refresh(); ev_poll(); while (ev_getevent(&ev)) { if (ev.type != EV_PRESS && ev.type != EV_RELEASE) continue; st = (ev.type != EV_RELEASE); rc_dokey(ev.code, st); } }
static PyObject* pyext_epoll_poll(PyObject *self,PyObject *args){ int ret; int epfd; int timeout; struct pyep_data *pyep; struct ev_data *evdata; PyObject *pylist; if(!PyArg_ParseTuple(args,"ii",&epfd,&timeout)){ PyErr_BadArgument(); return NULL; } if((pyep = pyep_getby_epfd(epfd)) == NULL){ PyErr_SetString(PyExc_KeyError,"epoll file descriptor not found"); return NULL; } evdata = &pyep->evdata; if((ret = ev_poll(evdata,timeout)) < 0){ //Preserve errno from ev_poll return PyErr_SetFromErrno(PyExc_SystemError); } if((pylist = PyList_New(ret)) == NULL){ return PyErr_NoMemory(); } for(;ret > 0;ret--){ PyList_SetItem(pylist,ret - 1,PyTuple_Pack( 2, PyLong_FromLong(evdata->polls[ret - 1].fd), PyLong_FromUnsignedLong(evdata->polls[ret - 1].events))); } return pylist; }