aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_thread_pool.h
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-08-17 11:03:57 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-08-17 11:03:57 +0100
commit55afdd2905dd1d9f58982691a404c373e768d304 (patch)
tree3a1a6bfbae95ac1dc7a0720fd3da82e192ec970f /src/lua/lua_thread_pool.h
parentf368a0a51e7073bdf244bf1a959fb5ccb0389b9b (diff)
downloadrspamd-55afdd2905dd1d9f58982691a404c373e768d304.tar.gz
rspamd-55afdd2905dd1d9f58982691a404c373e768d304.zip
[Minor] Added callback helpers
Diffstat (limited to 'src/lua/lua_thread_pool.h')
-rw-r--r--src/lua/lua_thread_pool.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/lua/lua_thread_pool.h b/src/lua/lua_thread_pool.h
index 64708c488..b72b72e8d 100644
--- a/src/lua/lua_thread_pool.h
+++ b/src/lua/lua_thread_pool.h
@@ -11,6 +11,13 @@ struct thread_entry {
struct thread_pool;
+struct lua_callback_state {
+ lua_State *L;
+ struct thread_entry *my_thread;
+ struct thread_entry *previous_thread;
+ struct lua_thread_pool *thread_pool;
+};
+
/**
* Allocates new thread pool on state L. Pre-creates number of lua-threads to use later on
*
@@ -67,7 +74,7 @@ lua_thread_pool_terminate_entry(struct lua_thread_pool *pool, struct thread_entr
* @return
*/
struct thread_entry *
-lua_thread_pool_get_running_entry(struct lua_thread_pool *pool);
+lua_thread_pool_get_running_entry (struct lua_thread_pool *pool);
/**
* Updates currently running thread
@@ -76,7 +83,24 @@ lua_thread_pool_get_running_entry(struct lua_thread_pool *pool);
* @param thread_entry
*/
void
-lua_thread_pool_set_running_entry(struct lua_thread_pool *pool, struct thread_entry *thread_entry);
+lua_thread_pool_set_running_entry (struct lua_thread_pool *pool, struct thread_entry *thread_entry);
+
+/**
+ * Prevents yielded thread to be used for callback execution. lua_thread_pool_restore_callback() should be called afterwards.
+ *
+ * @param pool
+ * @param cbs
+ */
+void
+lua_thread_pool_prepare_callback (struct lua_thread_pool *pool, struct lua_callback_state *cbs);
+
+/**
+ * Restores state after lua_thread_pool_prepare_callback () usage
+ *
+ * @param cbs
+ */
+void
+lua_thread_pool_restore_callback (struct lua_callback_state *cbs);
#endif /* LUA_THREAD_POOL_H_ */