/* * 功能:ev_periodic的回调函数 * 疑问:为何系统时间的更改会有一定的滞后性? */ void periodic_callback(struct ev_loop *loop, ev_periodic *w, int revents) { time_t now; printf("ev_iteration=%d\n", ev_iteration(loop)); printf("ev_pending_count=%d\n", ev_pending_count(loop)); printf("offset:%f,interval:%f\n", w->offset, w->interval); time(&now); printf("now timestamp:%lu\n", now); }
/** * Returns the current loop iteration. * * @return int * @return false if object is not initialized */ PHP_METHOD(EventLoop, getIteration) { event_loop_object *obj = (event_loop_object *)zend_object_store_get_object(getThis() TSRMLS_CC); assert(obj->loop); if(obj->loop) { RETURN_LONG(ev_iteration(obj->loop)); } RETURN_BOOL(0); }
static PyObject * Loop_iteration_get(Loop *self, void *closure) { return PyInt_FromUnsignedLong(ev_iteration(self->loop)); }