improve async

This commit is contained in:
lixianjing 2021-09-05 18:25:40 +08:00
parent 0dd70a9e28
commit 4af722bbb8
3 changed files with 6 additions and 3 deletions

View File

@ -21,6 +21,7 @@
#include "tkc/mem.h"
#include "tkc/action_thread_pool.h"
action_thread_pool_t* action_thread_pool_create(uint16_t max_thread_nr, uint16_t min_idle_nr) {
return action_thread_pool_create_ex(max_thread_nr, min_idle_nr, 0, TK_THREAD_PRIORITY_NORMAL);
}

View File

@ -77,9 +77,9 @@ ret_t async_call(async_exec_t exec, async_on_result_t on_result, void* ctx) {
return action_thread_pool_exec(s_async_thread_pool, a);
}
ret_t async_call_init(void) {
ret_t async_call_init(uint32_t max_threads, uint32_t min_threads) {
return_value_if_fail(s_async_thread_pool == NULL, RET_BAD_PARAMS);
s_async_thread_pool = action_thread_pool_create(5, 1);
s_async_thread_pool = action_thread_pool_create(max_threads, min_threads);
return_value_if_fail(s_async_thread_pool != NULL, RET_BAD_PARAMS);
return RET_OK;

View File

@ -57,11 +57,13 @@ ret_t async_call(async_exec_t exec, async_on_result_t on_result, void* ctx);
*
*
* @annotation ["static"]
* @param {uint32_t} max_threads 线
* @param {uint32_t} min_threads 线
*
* @return {ret_t} RET_OK表示成功
*
*/
ret_t async_call_init(void);
ret_t async_call_init(uint32_t max_threads, uint32_t min_threads);
/**
* @method async_call_deinit