diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-09 09:51:48 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-09 09:51:48 +0100 |
commit | f0e51f3ebecf0e8a3ae9c5c464d39d0cff26e96d (patch) | |
tree | 92b509a4eebf5c5a7b19481bbb3d4d703dfc1e0d /src/lua/lua_thread_pool.h | |
parent | 99ebeb7c1d3e9f32d46664ea2e91fa731d430e31 (diff) | |
download | rspamd-f0e51f3ebecf0e8a3ae9c5c464d39d0cff26e96d.tar.gz rspamd-f0e51f3ebecf0e8a3ae9c5c464d39d0cff26e96d.zip |
[Minor] Review fixes
Diffstat (limited to 'src/lua/lua_thread_pool.h')
-rw-r--r-- | src/lua/lua_thread_pool.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lua/lua_thread_pool.h b/src/lua/lua_thread_pool.h index 01643df9e..33a0da879 100644 --- a/src/lua/lua_thread_pool.h +++ b/src/lua/lua_thread_pool.h @@ -10,24 +10,70 @@ struct thread_entry { struct thread_pool; +/** + * Allocates new thread pool on state L. Pre-creates number of lua-threads to use later on + * + * @param L + * @return + */ struct lua_thread_pool * lua_thread_pool_new (lua_State * L); +/** + * Destroys the pool + * @param pool + */ void lua_thread_pool_free (struct lua_thread_pool *pool); +/** + * Extracts a thread from the list of available ones. + * It immediately becames running one and should be used to run a Lua script/function straight away. + * as soon as the code is finished, it should be either returned into list of available threads by + * calling lua_thread_pool_return() or terminated by calling lua_thread_pool_terminate_entry() + * if the code finished with error. + * + * If the code performed YIELD, the thread is still running and it's live should be controlled by the callee + * + * @param pool + * @return + */ struct thread_entry * lua_thread_pool_get(struct lua_thread_pool *pool); +/** + * Return thread into the list of available ones. It can't be done with yielded or dead threads. + * + * @param pool + * @param thread_entry + */ void lua_thread_pool_return(struct lua_thread_pool *pool, struct thread_entry *thread_entry); +/** + * Removes thread from Lua state. It should be done to dead (which ended with an error) threads only + * + * @param pool + * @param thread_entry + */ void lua_thread_pool_terminate_entry(struct lua_thread_pool *pool, struct thread_entry *thread_entry); +/** + * Currently running thread. Typically needed in yielding point - to fill-up continuation. + * + * @param pool + * @return + */ struct thread_entry * lua_thread_pool_get_running_entry(struct lua_thread_pool *pool); +/** + * Updates currently running thread + * + * @param pool + * @param thread_entry + */ void lua_thread_pool_set_running_entry(struct lua_thread_pool *pool, struct thread_entry *thread_entry); |