fast_allocator.[hc]: correct reclaim_interval logic

pull/37/merge
YuQing 2021-08-06 15:17:54 +08:00
parent 082a0fbc06
commit 47c4eaeb13
3 changed files with 12 additions and 9 deletions

View File

@ -1,4 +1,7 @@
Version 1.54 2021-08-06
* fast_allocator.[hc]: correct reclaim_interval logic
Version 1.53 2021-06-30 Version 1.53 2021-06-30
* process_action support action status * process_action support action status
* uniq_skiplist.h: add function uniq_skiplist_iterator_at * uniq_skiplist.h: add function uniq_skiplist_iterator_at

View File

@ -450,7 +450,7 @@ void *fast_allocator_alloc(struct fast_allocator_context *acontext,
ptr = fast_mblock_alloc_object(&allocator_info->mblock); ptr = fast_mblock_alloc_object(&allocator_info->mblock);
if (ptr == NULL) if (ptr == NULL)
{ {
if (acontext->allocator_array.reclaim_interval <= 0) if (acontext->allocator_array.reclaim_interval < 0)
{ {
return NULL; return NULL;
} }

View File

@ -47,7 +47,7 @@ struct fast_allocator_array
{ {
int count; int count;
int alloc; int alloc;
int reclaim_interval; //<= 0 for never reclaim int reclaim_interval; //< 0 for never reclaim
int last_reclaim_time; int last_reclaim_time;
volatile int64_t malloc_bytes; //total alloc bytes volatile int64_t malloc_bytes; //total alloc bytes
int64_t malloc_bytes_limit; //water mark bytes for malloc int64_t malloc_bytes_limit; //water mark bytes for malloc
@ -69,10 +69,10 @@ struct fast_allocator_context
#define FAST_ALLOCATOR_INIT_REGION(region, _start, _end, _step, _alloc_once) \ #define FAST_ALLOCATOR_INIT_REGION(region, _start, _end, _step, _alloc_once) \
do { \ do { \
region.start = _start; \ (region).start = _start; \
region.end = _end; \ (region).end = _end; \
region.step = _step; \ (region).step = _step; \
region.alloc_elements_once = _alloc_once; \ (region).alloc_elements_once = _alloc_once; \
} while(0) } while(0)
#ifdef __cplusplus #ifdef __cplusplus
@ -86,7 +86,7 @@ parameters:
mblock_name_prefix: the name prefix of mblock mblock_name_prefix: the name prefix of mblock
alloc_bytes_limit: the alloc limit, 0 for no limit alloc_bytes_limit: the alloc limit, 0 for no limit
expect_usage_ratio: the trunk usage ratio expect_usage_ratio: the trunk usage ratio
reclaim_interval: reclaim interval in second, 0 for never reclaim reclaim_interval: reclaim interval in second, < 0 for never reclaim
need_lock: if need lock need_lock: if need lock
return error no, 0 for success, != 0 fail return error no, 0 for success, != 0 fail
*/ */
@ -103,7 +103,7 @@ parameters:
region_count: the region count region_count: the region count
alloc_bytes_limit: the alloc limit, 0 for no limit alloc_bytes_limit: the alloc limit, 0 for no limit
expect_usage_ratio: the trunk usage ratio expect_usage_ratio: the trunk usage ratio
reclaim_interval: reclaim interval in second, 0 for never reclaim reclaim_interval: reclaim interval in second, < 0 for never reclaim
need_lock: if need lock need_lock: if need lock
return error no, 0 for success, != 0 fail return error no, 0 for success, != 0 fail
*/ */