int lua_uv_timer_again(lua_State * L) { uv_timer_t * t = lua_generic_object<uv_timer_t>(L, 1); uv_timer_again(t); lua_uv_ok(L); lua_settop(L, 1); return 1; // return timer }
static int lua_time_interval(lua_State * L) { int ret = 0,t=lua_type(L,2); luatimer_t * tm = (luatimer_t *)luaL_checkudata(L, 1,UVLUA_TIMER_CLS); if(NULL != tm){ if(LUA_TNIL != t && LUA_TNONE !=t){ int repeat = lua_tointeger(L, 2); if(repeat > 0){ uv_loop_t * loop = tm->timer.loop; int restart = 0; if(uv_is_active((uv_handle_t *)&tm->timer)){ uv_timer_stop(&tm->timer); restart=1; } uv_timer_set_repeat(&tm->timer, repeat); if(restart) uv_timer_again(&tm->timer); } } lua_pushinteger(L, uv_timer_get_repeat(&tm->timer)); }else{ lua_pushinteger(L, 0); } return 1; }
static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) { uv_loop_t *loop = handle->loop; struct session *s = handle->data; struct worker_ctx *worker = loop->data; /* TCP pipelining is rather complicated and requires cooperation from the worker * so the whole message reassembly and demuxing logic is inside worker */ int ret = 0; if (s->has_tls) { ret = tls_process(worker, handle, (const uint8_t *)buf->base, nread); } else { ret = worker_process_tcp(worker, handle, (const uint8_t *)buf->base, nread); } if (ret < 0) { worker_end_tcp(worker, (uv_handle_t *)handle); /* Exceeded per-connection quota for outstanding requests * stop reading from stream and close after last message is processed. */ if (!s->outgoing && !uv_is_closing((uv_handle_t *)&s->timeout)) { uv_timer_stop(&s->timeout); if (s->tasks.len == 0) { uv_close((uv_handle_t *)&s->timeout, tcp_timeout); } else { /* If there are tasks running, defer until they finish. */ uv_timer_start(&s->timeout, tcp_timeout_trigger, 1, KR_CONN_RTT_MAX/2); } } /* Connection spawned more than one request, reset its deadline for next query. */ } else if (ret > 0 && !s->outgoing) { uv_timer_again(&s->timeout); } mp_flush(worker->pkt_pool.ctx); }
int luv_timer_again(lua_State* L) { uv_timer_t* handle = (uv_timer_t*)luv_checkudata(L, 1, "timer"); int err = uv_timer_again(handle); if (err < 0) { return luaL_error(L, "timer_again: %s", uv_strerror(err)); } return 0; }
static void tcp_timeout_trigger(uv_timer_t *timer) { uv_handle_t *handle = timer->data; struct session *session = handle->data; if (session->tasks.len > 0) { uv_timer_again(timer); } else { uv_close((uv_handle_t *)timer, tcp_timeout); } }
void uv__run_timers(uv_loop_t* loop) { uv_timer_t* handle; while ((handle = RB_MIN(uv__timers, &loop->timer_handles))) { if (handle->timeout > loop->time) break; uv_timer_stop(handle); uv_timer_again(handle); handle->timer_cb(handle, 0); } }
static int lua_time_start(lua_State * L) { int ret = -1; luatimer_t * tm = (luatimer_t *)luaL_checkudata(L, 1,UVLUA_TIMER_CLS); if(NULL != tm){ ret = uv_timer_again(&tm->timer); } lua_pushinteger(L,ret); return 1; }
/* * Class: com_oracle_libuv_handles_TimerHandle * Method: _again * Signature: (J)I */ JNIEXPORT jint JNICALL Java_com_oracle_libuv_handles_TimerHandle__1again (JNIEnv *env, jobject that, jlong timer) { assert(timer); uv_timer_t* handle = reinterpret_cast<uv_timer_t*>(timer); int r = uv_timer_again(handle); if (r) { ThrowException(env, handle->loop, "uv_timer_again"); } return r; }
static void uv__ares_io(struct ev_loop* ev, struct ev_io* watcher, int revents) { uv_loop_t* loop = ev_userdata(ev); assert(ev == loop->ev); /* Reset the idle timer */ uv_timer_again(&loop->timer); /* Process DNS responses */ ares_process_fd(loop->channel, revents & EV_READ ? watcher->fd : ARES_SOCKET_BAD, revents & EV_WRITE ? watcher->fd : ARES_SOCKET_BAD); }
static PyObject * Timer_func_again(Timer *self) { int r; RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL); r = uv_timer_again((uv_timer_t *)UV_HANDLE(self)); if (r != 0) { RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_TimerError); return NULL; } Py_RETURN_NONE; }
static PyObject * Timer_func_again(Timer *self) { int err; RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL); RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL); err = uv_timer_again(&self->timer_h); if (err < 0) { RAISE_UV_EXCEPTION(err, PyExc_TimerError); return NULL; } Py_RETURN_NONE; }
static void defer_cb(uv_timer_t *handle #if UV_VERSION_MAJOR < 1 , int status #endif ) { dfr_t *d = (dfr_t *)handle->data; #if UV_VERSION_MAJOR < 1 IOT_UNUSED(status); #endif d->cb(d->glue_data, d, d->user_data); if (d->enabled) uv_timer_again(&d->uv_tmr); }
void pc__heartbeat_cb(uv_timer_t* heartbeat_timer, int status) { uv_timer_stop(heartbeat_timer); pc_client_t *client = (pc_client_t *)heartbeat_timer->data; if(status == -1) { fprintf(stderr, "Pomelo heartbeat timer error, %s\n", uv_err_name(uv_last_error(client->uv_loop))); pc_client_stop(client); return; } if(pc__heartbeat_req(client)) { pc_client_stop(client); return; } uv_timer_again(client->timeout_timer); }
void uv__run_timers(uv_loop_t* loop) { struct heap_node* heap_node; uv_timer_t* handle; for (;;) { heap_node = heap_min(timer_heap(loop)); if (heap_node == NULL) break; handle = container_of(heap_node, uv_timer_t, heap_node); if (handle->timeout > loop->time) break; uv_timer_stop(handle); uv_timer_again(handle); handle->timer_cb(handle); } }
static void repeat_1_cb(uv_timer_t* handle) { int r; TUV_ASSERT(handle == &repeat_1); TUV_ASSERT(uv_timer_get_repeat((uv_timer_t*)handle) == 50); repeat_1_cb_called++; r = uv_timer_again(&repeat_2); TUV_ASSERT(r == 0); if (repeat_1_cb_called == 10) { uv_close((uv_handle_t*)handle, close_cb); /* We're not calling uv_timer_again on repeat_2 any more, so after this */ /* timer_2_cb is expected. */ repeat_2_cb_allowed = 1; return; } }
static void repeat_1_cb(uv_timer_t* handle) { int r; ASSERT(handle == &repeat_1); ASSERT(uv_timer_get_repeat((uv_timer_t*)handle) == 50); LOGF("repeat_1_cb called after %ld ms\n", (long int)(uv_now(uv_default_loop()) - start_time)); repeat_1_cb_called++; r = uv_timer_again(&repeat_2); ASSERT(r == 0); if (repeat_1_cb_called == 10) { uv_close((uv_handle_t*)handle, close_cb); /* We're not calling uv_timer_again on repeat_2 any more, so after this */ /* timer_2_cb is expected. */ repeat_2_cb_allowed = 1; return; } }
void again() { uv_timer_again(phandle()); }
static void(timer_again)(void* t) { struct LwqqAsyncTimer_* t_ = (struct LwqqAsyncTimer_*)t; uv_timer_again(&t_->h); }
int pc__heartbeat(pc_client_t *client) { uv_timer_stop(client->timeout_timer); uv_timer_again(client->heartbeat_timer); return 0; }