mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
bugfix: skynet.coroutine
This commit is contained in:
@@ -107,7 +107,7 @@ lstop(lua_State *L) {
|
|||||||
total_time += ti;
|
total_time += ti;
|
||||||
lua_pushnumber(L, total_time);
|
lua_pushnumber(L, total_time);
|
||||||
#ifdef DEBUG_LOG
|
#ifdef DEBUG_LOG
|
||||||
fprintf(stderr, "PROFILE [%p] stop (%lf / %lf)\n", L, ti, total_time);
|
fprintf(stderr, "PROFILE [%p] stop (%lf / %lf)\n", lua_tothread(L,1), ti, total_time);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -157,14 +157,15 @@ timing_yield(lua_State *L) {
|
|||||||
#ifdef DEBUG_LOG
|
#ifdef DEBUG_LOG
|
||||||
lua_State *from = lua_tothread(L, -1);
|
lua_State *from = lua_tothread(L, -1);
|
||||||
#endif
|
#endif
|
||||||
|
lua_pushvalue(L, -1);
|
||||||
lua_rawget(L, lua_upvalueindex(2)); // check total time
|
lua_rawget(L, lua_upvalueindex(2)); // check total time
|
||||||
if (lua_isnil(L, -1)) {
|
if (lua_isnil(L, -1)) {
|
||||||
lua_pop(L,1);
|
lua_pop(L,2);
|
||||||
} else {
|
} else {
|
||||||
double ti = lua_tonumber(L, -1);
|
double ti = lua_tonumber(L, -1);
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
|
|
||||||
lua_pushthread(L);
|
lua_pushvalue(L, -1); // push coroutine
|
||||||
lua_rawget(L, lua_upvalueindex(1));
|
lua_rawget(L, lua_upvalueindex(1));
|
||||||
double starttime = lua_tonumber(L, -1);
|
double starttime = lua_tonumber(L, -1);
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
@@ -175,9 +176,10 @@ timing_yield(lua_State *L) {
|
|||||||
fprintf(stderr, "PROFILE [%p] yield (%lf/%lf)\n", from, diff, ti);
|
fprintf(stderr, "PROFILE [%p] yield (%lf/%lf)\n", from, diff, ti);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lua_pushthread(L);
|
lua_pushvalue(L, -1); // push coroutine
|
||||||
lua_pushnumber(L, ti);
|
lua_pushnumber(L, ti);
|
||||||
lua_rawset(L, lua_upvalueindex(2));
|
lua_rawset(L, lua_upvalueindex(2));
|
||||||
|
lua_pop(L, 1); // pop coroutine
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_CFunction co_yield = lua_tocfunction(L, lua_upvalueindex(3));
|
lua_CFunction co_yield = lua_tocfunction(L, lua_upvalueindex(3));
|
||||||
|
|||||||
Reference in New Issue
Block a user