uniq_skiplist.[hc]: init function add parameter: allocator_use_lock

iovec_array
YuQing 2021-05-20 10:08:01 +08:00
parent 797f4e08b8
commit df4fdfcab7
4 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,7 @@
Version 1.51 2021-05-18 Version 1.51 2021-05-20
* fast_mblock.[hc]: support batch alloc and batch free * fast_mblock.[hc]: support batch alloc and batch free
* uniq_skiplist.[hc]: init function add parameter: allocator_use_lock
Version 1.50 2021-05-11 Version 1.50 2021-05-11
* add function is_digital_string * add function is_digital_string

View File

@ -179,6 +179,12 @@ typedef struct
char patch; char patch;
} Version; } Version;
typedef struct
{
char **strs;
int count;
} str_ptr_array_t;
typedef struct typedef struct
{ {
char *key; char *key;

View File

@ -54,7 +54,7 @@ int uniq_skiplist_init_ex2(UniqSkiplistFactory *factory,
const int max_level_count, skiplist_compare_func compare_func, const int max_level_count, skiplist_compare_func compare_func,
uniq_skiplist_free_func free_func, const int alloc_skiplist_once, uniq_skiplist_free_func free_func, const int alloc_skiplist_once,
const int min_alloc_elements_once, const int delay_free_seconds, const int min_alloc_elements_once, const int delay_free_seconds,
const bool bidirection) const bool bidirection, const bool allocator_use_lock)
{ {
const int64_t alloc_elements_limit = 0; const int64_t alloc_elements_limit = 0;
char name[64]; char name[64];
@ -105,7 +105,8 @@ int uniq_skiplist_init_ex2(UniqSkiplistFactory *factory,
sizeof(UniqSkiplistNode *) * (i + 1 + extra_links_count); sizeof(UniqSkiplistNode *) * (i + 1 + extra_links_count);
if ((result=fast_mblock_init_ex1(factory->node_allocators + i, if ((result=fast_mblock_init_ex1(factory->node_allocators + i,
name, element_size, alloc_elements_once, name, element_size, alloc_elements_once,
alloc_elements_limit, NULL, NULL, false)) != 0) alloc_elements_limit, NULL, NULL,
allocator_use_lock)) != 0)
{ {
return result; return result;
} }
@ -117,7 +118,8 @@ int uniq_skiplist_init_ex2(UniqSkiplistFactory *factory,
if ((result=fast_mblock_init_ex1(&factory->skiplist_allocator, if ((result=fast_mblock_init_ex1(&factory->skiplist_allocator,
"skiplist", sizeof(UniqSkiplist), "skiplist", sizeof(UniqSkiplist),
alloc_skiplist_once > 0 ? alloc_skiplist_once : alloc_skiplist_once > 0 ? alloc_skiplist_once :
4 * 1024, alloc_elements_limit, NULL, NULL, false)) != 0) 4 * 1024, alloc_elements_limit, NULL, NULL,
allocator_use_lock)) != 0)
{ {
return result; return result;
} }

View File

@ -75,7 +75,7 @@ extern "C" {
delay_free_seconds) \ delay_free_seconds) \
uniq_skiplist_init_ex2(factory, max_level_count, compare_func, \ uniq_skiplist_init_ex2(factory, max_level_count, compare_func, \
free_func, alloc_skiplist_once, min_alloc_elements_once, \ free_func, alloc_skiplist_once, min_alloc_elements_once, \
delay_free_seconds, false) delay_free_seconds, false, false)
#define uniq_skiplist_init(factory, max_level_count, compare_func, free_func) \ #define uniq_skiplist_init(factory, max_level_count, compare_func, free_func) \
uniq_skiplist_init_ex(factory, max_level_count, \ uniq_skiplist_init_ex(factory, max_level_count, \
@ -102,7 +102,7 @@ int uniq_skiplist_init_ex2(UniqSkiplistFactory *factory,
const int max_level_count, skiplist_compare_func compare_func, const int max_level_count, skiplist_compare_func compare_func,
uniq_skiplist_free_func free_func, const int alloc_skiplist_once, uniq_skiplist_free_func free_func, const int alloc_skiplist_once,
const int min_alloc_elements_once, const int delay_free_seconds, const int min_alloc_elements_once, const int delay_free_seconds,
const bool bidirection); const bool bidirection, const bool allocator_use_lock);
void uniq_skiplist_destroy(UniqSkiplistFactory *factory); void uniq_skiplist_destroy(UniqSkiplistFactory *factory);
@ -118,12 +118,13 @@ static inline int uniq_skiplist_init_pair_ex(UniqSkiplistPair *pair,
const int delay_free_seconds, const bool bidirection) const int delay_free_seconds, const bool bidirection)
{ {
const int alloc_skiplist_once = 1; const int alloc_skiplist_once = 1;
const bool allocator_use_lock = false;
int result; int result;
if ((result=uniq_skiplist_init_ex2(&pair->factory, max_level_count, if ((result=uniq_skiplist_init_ex2(&pair->factory, max_level_count,
compare_func, free_func, alloc_skiplist_once, compare_func, free_func, alloc_skiplist_once,
min_alloc_elements_once, delay_free_seconds, min_alloc_elements_once, delay_free_seconds,
bidirection)) != 0) bidirection, allocator_use_lock)) != 0)
{ {
return result; return result;
} }