MCPcopy Create free account
hub / github.com/apache/trafficserver / ts_lua_sleep_ms

Function ts_lua_sleep_ms

plugins/lua/ts_lua_misc.cc:402–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402static int
403ts_lua_sleep_ms(lua_State *L)
404{
405 int msec;
406 TSAction action;
407 TSCont contp;
408 ts_lua_async_item *ai;
409 ts_lua_cont_info *ci;
410
411 ci = ts_lua_get_cont_info(L);
412 if (ci == nullptr) {
413 TSError("[ts_lua][%s] no cont info found", __FUNCTION__);
414 TSReleaseAssert(!"Unexpected fetch of cont info");
415 return 0;
416 }
417
418 msec = luaL_checknumber(L, 1);
419 if (msec < 1) {
420 msec = 1;
421 }
422
423 contp = TSContCreate(ts_lua_sleep_handler, ci->mutex);
424 action = TSContScheduleOnPool(contp, msec, TS_THREAD_POOL_NET);
425
426 ai = ts_lua_async_create_item(contp, ts_lua_sleep_cleanup, (void *)action, ci);
427 TSContDataSet(contp, ai);
428
429 return lua_yield(L, 0);
430}
431
432static int
433ts_lua_sleep(lua_State *L)

Callers

nothing calls this directly

Calls 6

ts_lua_get_cont_infoFunction · 0.85
TSContCreateFunction · 0.85
TSContScheduleOnPoolFunction · 0.85
ts_lua_async_create_itemFunction · 0.85
TSContDataSetFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected