summaryrefslogtreecommitdiffstats
path: root/src/lua/lua_thread_pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/lua_thread_pool.c')
-rw-r--r--src/lua/lua_thread_pool.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lua/lua_thread_pool.c b/src/lua/lua_thread_pool.c
index 3fc14534d..df3ed775e 100644
--- a/src/lua/lua_thread_pool.c
+++ b/src/lua/lua_thread_pool.c
@@ -158,6 +158,20 @@ lua_thread_pool_set_running_entry (struct lua_thread_pool *pool, struct thread_e
pool->running_entry = thread_entry;
}
+static void
+lua_thread_pool_set_running_entry_for_thread (struct thread_entry *thread_entry)
+{
+ struct lua_thread_pool *pool;
+
+ if (thread_entry->task) {
+ pool = thread_entry->task->cfg->lua_thread_pool;
+ }
+ else {
+ pool = thread_entry->cfg->lua_thread_pool;
+ }
+
+ lua_thread_pool_set_running_entry (pool, thread_entry);
+}
void
lua_thread_pool_prepare_callback (struct lua_thread_pool *pool, struct lua_callback_state *cbs)
@@ -206,6 +220,8 @@ lua_thread_resume (struct thread_entry *thread_entry, gint narg)
*/
g_assert (lua_status (thread_entry->lua_state) == LUA_YIELD);
+ lua_thread_pool_set_running_entry_for_thread(thread_entry);
+
lua_resume_thread_internal (thread_entry, narg);
}
@@ -263,5 +279,7 @@ lua_resume_thread_internal (struct thread_entry *thread_entry, gint narg)
gint
lua_thread_yield (struct thread_entry *thread_entry, gint nresults)
{
+ g_assert (lua_status (thread_entry->lua_state) == 0);
+
return lua_yield (thread_entry->lua_state, nresults);
}