Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿啄debugIT
libfastcommon
提交
58e1aea3
L
libfastcommon
项目概览
阿啄debugIT
/
libfastcommon
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libfastcommon
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
58e1aea3
编写于
11月 03, 2020
作者:
Y
YuQing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add function: fc_queue_empty
上级
5f9bfd8b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
43 addition
and
13 deletion
+43
-13
HISTORY
HISTORY
+1
-1
src/fast_mblock.c
src/fast_mblock.c
+3
-1
src/fast_mblock.h
src/fast_mblock.h
+3
-2
src/fc_queue.h
src/fc_queue.h
+16
-1
src/pthread_func.h
src/pthread_func.h
+1
-0
src/sched_thread.h
src/sched_thread.h
+19
-8
未找到文件。
HISTORY
浏览文件 @
58e1aea3
Version 1.44 2020-1
0-31
Version 1.44 2020-1
1-03
* add test file src/tests/test_pthread_lock.c
* add uniq_skiplist.[hc]
* add function split_string_ex
...
...
src/fast_mblock.c
浏览文件 @
58e1aea3
...
...
@@ -425,6 +425,7 @@ int fast_mblock_init_ex2(struct fast_mblock_man *mblock, const char *name,
mblock
->
info
.
trunk_size
=
fast_mblock_get_trunk_size
(
mblock
,
block_size
,
mblock
->
alloc_elements
.
once
);
mblock
->
need_lock
=
need_lock
;
mblock
->
exceed_log_level
=
LOG_ERR
;
mblock
->
malloc_trunk_callback
.
check_func
=
malloc_trunk_check
;
mblock
->
malloc_trunk_callback
.
notify_func
=
malloc_trunk_notify
;
mblock
->
malloc_trunk_callback
.
args
=
malloc_trunk_args
;
...
...
@@ -463,7 +464,8 @@ static int fast_mblock_prealloc(struct fast_mblock_man *mblock)
mblock
->
info
.
element_total_count
;
if
(
avail_count
<=
0
)
{
logError
(
"file: "
__FILE__
", line: %d, "
log_it_ex
(
&
g_log_context
,
mblock
->
exceed_log_level
,
"file: "
__FILE__
", line: %d, "
"allocated elements exceed limit: %"
PRId64
,
__LINE__
,
mblock
->
alloc_elements
.
limit
);
return
EOVERFLOW
;
...
...
src/fast_mblock.h
浏览文件 @
58e1aea3
...
...
@@ -102,8 +102,9 @@ struct fast_mblock_man
fast_mblock_alloc_init_func
alloc_init_func
;
struct
fast_mblock_malloc_trunk_callback
malloc_trunk_callback
;
bool
need_lock
;
//if need mutex lock
pthread_mutex_t
lock
;
//the lock for read / write free node chain
bool
need_lock
;
//if need mutex lock
int
exceed_log_level
;
//log level for exceed limit
pthread_mutex_t
lock
;
//the lock for read / write free node chain
struct
fast_mblock_man
*
prev
;
//for stat manager
struct
fast_mblock_man
*
next
;
//for stat manager
void
*
init_args
;
//args for alloc_init_func
...
...
src/fc_queue.h
浏览文件 @
58e1aea3
...
...
@@ -23,7 +23,6 @@
#include <string.h>
#include <pthread.h>
#include "common_define.h"
#include "fast_mblock.h"
struct
fc_queue_info
{
...
...
@@ -74,6 +73,12 @@ static inline void fc_queue_push(struct fc_queue *queue, void *data)
}
}
static
inline
void
fc_queue_push_silence
(
struct
fc_queue
*
queue
,
void
*
data
)
{
bool
notify
;
fc_queue_push_ex
(
queue
,
data
,
&
notify
);
}
void
fc_queue_push_queue_to_head_ex
(
struct
fc_queue
*
queue
,
struct
fc_queue_info
*
qinfo
,
bool
*
notify
);
...
...
@@ -99,6 +104,16 @@ void *fc_queue_pop_all_ex(struct fc_queue *queue, const bool blocked);
void
fc_queue_pop_to_queue
(
struct
fc_queue
*
queue
,
struct
fc_queue_info
*
qinfo
);
static
inline
bool
fc_queue_empty
(
struct
fc_queue
*
queue
)
{
bool
empty
;
pthread_mutex_lock
(
&
queue
->
lc_pair
.
lock
);
empty
=
(
queue
->
head
==
NULL
);
pthread_mutex_unlock
(
&
queue
->
lc_pair
.
lock
);
return
empty
;
}
#ifdef __cplusplus
}
#endif
...
...
src/pthread_func.h
浏览文件 @
58e1aea3
...
...
@@ -23,6 +23,7 @@
#include <sys/time.h>
#include <sys/resource.h>
#include "common_define.h"
#include "logger.h"
#include "sched_thread.h"
#ifdef __cplusplus
...
...
src/sched_thread.h
浏览文件 @
58e1aea3
...
...
@@ -81,25 +81,36 @@ typedef struct
bool
*
pcontinue_flag
;
}
ScheduleContext
;
#define INIT_SCHEDULE_ENTRY(schedule_entry, _id, _hour, _minute, _second, \
_interval, _task_func, _func_args) \
#define INIT_SCHEDULE_ENTRY
1
(schedule_entry, _id, _hour, _minute, _second, \
_interval, _task_func, _func_args
, _new_thread
) \
(schedule_entry).id = _id; \
(schedule_entry).time_base.hour = _hour; \
(schedule_entry).time_base.minute = _minute; \
(schedule_entry).time_base.second = _second; \
(schedule_entry).interval = _interval; \
(schedule_entry).task_func = _task_func; \
(schedule_entry).
new_thread = false;
\
(schedule_entry).
func_args = _func_args
(schedule_entry).
func_args = _func_args;
\
(schedule_entry).
new_thread = _new_thread
#define INIT_SCHEDULE_ENTRY_EX(schedule_entry, _id, _time_base, \
_interval, _task_func, _func_args) \
#define INIT_SCHEDULE_ENTRY_EX
1
(schedule_entry, _id, _time_base, \
_interval, _task_func, _func_args
, _new_thread
) \
(schedule_entry).id = _id; \
(schedule_entry).time_base = _time_base; \
(schedule_entry).interval = _interval; \
(schedule_entry).task_func = _task_func; \
(schedule_entry).new_thread = false; \
(schedule_entry).func_args = _func_args
(schedule_entry).func_args = _func_args; \
(schedule_entry).new_thread = _new_thread
#define INIT_SCHEDULE_ENTRY(schedule_entry, _id, _hour, _minute, _second, \
_interval, _task_func, _func_args) \
INIT_SCHEDULE_ENTRY1(schedule_entry, _id, _hour, _minute, _second, \
_interval, _task_func, _func_args, false)
#define INIT_SCHEDULE_ENTRY_EX(schedule_entry, _id, _time_base, \
_interval, _task_func, _func_args) \
INIT_SCHEDULE_ENTRY_EX1(schedule_entry, _id, _time_base, \
_interval, _task_func, _func_args, false)
#ifdef __cplusplus
extern
"C"
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录