MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaB_costatus

Function luaB_costatus

freebsd/contrib/openzfs/module/lua/lcorolib.c:102–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102static int luaB_costatus (lua_State *L) {
103 lua_State *co = lua_tothread(L, 1);
104 luaL_argcheck(L, co, 1, "coroutine expected");
105 if (L == co) lua_pushliteral(L, "running");
106 else {
107 switch (lua_status(co)) {
108 case LUA_YIELD:
109 lua_pushliteral(L, "suspended");
110 break;
111 case LUA_OK: {
112 lua_Debug ar;
113 if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
114 lua_pushliteral(L, "normal"); /* it is running */
115 else if (lua_gettop(co) == 0)
116 lua_pushliteral(L, "dead");
117 else
118 lua_pushliteral(L, "suspended"); /* initial state */
119 break;
120 }
121 default: /* some error occurred */
122 lua_pushliteral(L, "dead");
123 break;
124 }
125 }
126 return 1;
127}
128
129
130static int luaB_corunning (lua_State *L) {

Callers

nothing calls this directly

Calls 4

lua_tothreadFunction · 0.70
lua_statusFunction · 0.70
lua_getstackFunction · 0.70
lua_gettopFunction · 0.70

Tested by

no test coverage detected