aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_thread_pool.c
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-08-24 09:13:24 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-08-24 09:13:24 +0100
commit6d12ba86f224b77a5047643e7c304fef1d763b26 (patch)
tree2a349f5107a18d2d0f8d8d5a2bfece1c93e6c83a /src/lua/lua_thread_pool.c
parented9d4ec8c8b62664f0157ccb6dceaba264e1891b (diff)
downloadrspamd-6d12ba86f224b77a5047643e7c304fef1d763b26.tar.gz
rspamd-6d12ba86f224b77a5047643e7c304fef1d763b26.zip
[Minor] Split lua_thread_pool_get on lua_thread_pool_get_for_task/lua_thread_pool_get_for_config
Diffstat (limited to 'src/lua/lua_thread_pool.c')
-rw-r--r--src/lua/lua_thread_pool.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/lua/lua_thread_pool.c b/src/lua/lua_thread_pool.c
index 4c1681f96..3fc14534d 100644
--- a/src/lua/lua_thread_pool.c
+++ b/src/lua/lua_thread_pool.c
@@ -60,12 +60,35 @@ lua_thread_pool_free (struct lua_thread_pool *pool)
g_free (pool);
}
+struct thread_entry *lua_thread_pool_get_for_config (struct rspamd_config *cfg);
+
+static struct thread_entry *lua_thread_pool_get (struct lua_thread_pool *pool);
+
struct thread_entry *
+lua_thread_pool_get_for_task (struct rspamd_task *task)
+{
+ struct thread_entry *ent = lua_thread_pool_get (task->cfg->lua_thread_pool);
+
+ ent->task = task;
+
+ return ent;
+}
+
+struct thread_entry *
+lua_thread_pool_get_for_config (struct rspamd_config *cfg)
+{
+ struct thread_entry *ent = lua_thread_pool_get (cfg->lua_thread_pool);
+
+ ent->cfg = cfg;
+
+ return ent;
+}
+
+static struct thread_entry *
lua_thread_pool_get (struct lua_thread_pool *pool)
{
gpointer cur;
struct thread_entry *ent = NULL;
-
cur = g_queue_pop_head (pool->available_items);
if (cur) {
@@ -174,7 +197,7 @@ lua_thread_call (struct thread_entry *thread_entry, int narg)
}
void
-lua_resume_thread (struct thread_entry *thread_entry, gint narg)
+lua_thread_resume (struct thread_entry *thread_entry, gint narg)
{
/*
* The only state where we can resume from is LUA_YIELD
@@ -235,4 +258,10 @@ lua_resume_thread_internal (struct thread_entry *thread_entry, gint narg)
lua_thread_pool_terminate_entry (pool, thread_entry);
}
}
-} \ No newline at end of file
+}
+
+gint
+lua_thread_yield (struct thread_entry *thread_entry, gint nresults)
+{
+ return lua_yield (thread_entry->lua_state, nresults);
+}