Smaller threads data structure
This commit is contained in:
@@ -208,8 +208,8 @@ void World::invoke_plan(int64_t actor_id, int64_t place_id, const std::string &a
|
||||
|
||||
// Set up for Lua manipulation.
|
||||
lua_State *L = state();
|
||||
LuaVar actor, place, func, tangibles, mt, index, actions, threadtab, thread, threadinfo, message;
|
||||
LuaStack LS(L, actor, place, func, tangibles, mt, index, actions, threadtab, thread, threadinfo, message);
|
||||
LuaVar actor, place, func, tangibles, mt, index, actions, thread, threads, message;
|
||||
LuaStack LS(L, actor, place, func, tangibles, mt, index, actions, thread, threads, message);
|
||||
|
||||
// Get the actor and place.
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
@@ -251,14 +251,12 @@ void World::invoke_plan(int64_t actor_id, int64_t place_id, const std::string &a
|
||||
lua_xmove(L, CO, 4);
|
||||
|
||||
// Store the thread into place's thread table.
|
||||
LS.rawget(threadtab, mt, "threads");
|
||||
if (!LS.istable(threadtab)) {
|
||||
LS.rawget(threads, mt, "threads");
|
||||
if (!LS.istable(threads)) {
|
||||
LS.result();
|
||||
return;
|
||||
}
|
||||
LS.set(threadinfo, LuaNewTable);
|
||||
LS.rawset(threadinfo, "thread", thread);
|
||||
LS.rawset(threadtab, tid, threadinfo);
|
||||
LS.rawset(threads, tid, thread);
|
||||
LS.result();
|
||||
|
||||
// Push the thread's ID into the runnable thread queue,
|
||||
@@ -273,8 +271,8 @@ void World::enqueue_thread(int64_t tid, int64_t place_id) {
|
||||
|
||||
void World::run_thread(int64_t tid, int64_t place_id) {
|
||||
lua_State *L = state();
|
||||
LuaVar tangibles, place, mt, threads, threadtab, thread;
|
||||
LuaStack LS(L, tangibles, place, mt, threads, threadtab, thread);
|
||||
LuaVar tangibles, place, mt, threads, thread;
|
||||
LuaStack LS(L, tangibles, place, mt, threads, thread);
|
||||
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
LS.rawget(place, tangibles, place_id);
|
||||
@@ -292,17 +290,11 @@ void World::run_thread(int64_t tid, int64_t place_id) {
|
||||
LS.result();
|
||||
return;
|
||||
}
|
||||
LS.rawget(threadtab, threads, tid);
|
||||
if (!LS.istable(threadtab)) {
|
||||
LS.result();
|
||||
return;
|
||||
}
|
||||
LS.rawget(thread, threadtab, "thread");
|
||||
LS.rawget(thread, threads, tid);
|
||||
if (!LS.isthread(thread)) {
|
||||
LS.result();
|
||||
return;
|
||||
}
|
||||
LS.rawset(threadtab, "wake", LuaNil);
|
||||
|
||||
// Resume the coroutine.
|
||||
lua_State *CO = LS.ckthread(thread);
|
||||
|
||||
Reference in New Issue
Block a user