Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4013985
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a4013985
编写于
9月 17, 2022
作者:
Z
zhihaop
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: remove unnecessary atomic variable usage
上级
9d6f980b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
14 addition
and
15 deletion
+14
-15
src/client/inc/tscBulkWrite.h
src/client/inc/tscBulkWrite.h
+5
-5
src/client/src/tscBulkWrite.c
src/client/src/tscBulkWrite.c
+9
-10
未找到文件。
src/client/inc/tscBulkWrite.h
浏览文件 @
a4013985
...
...
@@ -49,12 +49,12 @@ typedef struct SAsyncBulkWriteDispatcher {
// the batching timeout in milliseconds.
int32_t
timeoutMs
;
// the number of insertion rows in the buffer.
int32_t
currentSize
;
// the number of item in the buffer.
volatile
int32_t
bufferSize
;
// the number of insertion rows in the buffer.
volatile
int32_t
currentSize
;
// while executing timeout task, the buffer will set exclusive for writing.
volatile
bool
exclusive
;
...
...
src/client/src/tscBulkWrite.c
浏览文件 @
a4013985
...
...
@@ -161,8 +161,8 @@ inline static SArray* dispatcherPollAll(SAsyncBulkWriteDispatcher* dispatcher) {
return
NULL
;
}
dispatcher
->
currentSize
=
0
;
atomic_store_32
(
&
dispatcher
->
bufferSize
,
0
);
atomic_store_32
(
&
dispatcher
->
currentSize
,
0
);
taosArrayClear
(
dispatcher
->
buffer
);
return
statements
;
}
...
...
@@ -195,14 +195,14 @@ inline static bool dispatcherTryOffer(SAsyncBulkWriteDispatcher* dispatcher, SSq
// usually not happen, unless taos_query_a(...) after taos_close(...).
if
(
atomic_load_8
(
&
dispatcher
->
shutdown
))
{
pthread_mutex_unlock
(
&
dispatcher
->
mutex
);
return
-
1
;
return
false
;
}
// the buffer is full.
while
(
atomic_load_32
(
&
dispatcher
->
currentSize
)
>=
dispatcher
->
batchSize
)
{
while
(
dispatcher
->
currentSize
>=
dispatcher
->
batchSize
)
{
if
(
pthread_cond_wait
(
&
dispatcher
->
notFull
,
&
dispatcher
->
mutex
))
{
pthread_mutex_unlock
(
&
dispatcher
->
mutex
);
return
-
1
;
return
false
;
}
}
...
...
@@ -210,18 +210,17 @@ inline static bool dispatcherTryOffer(SAsyncBulkWriteDispatcher* dispatcher, SSq
tscDebug
(
"sql obj %p has been write to insert buffer"
,
pSql
);
atomic_fetch_add_32
(
&
dispatcher
->
bufferSize
,
1
);
int32_t
numOfRows
=
statementGetInsertionRows
(
pSql
);
int32_t
currentSize
=
atomic_add_fetch_32
(
&
dispatcher
->
currentSize
,
numOfRows
);
dispatcher
->
currentSize
+=
statementGetInsertionRows
(
pSql
);
// the dispatcher has been shutdown or reach batch size.
if
(
atomic_load_8
(
&
dispatcher
->
shutdown
)
||
currentSize
>=
dispatcher
->
batchSize
)
{
if
(
atomic_load_8
(
&
dispatcher
->
shutdown
)
||
dispatcher
->
currentSize
>=
dispatcher
->
batchSize
)
{
SArray
*
statements
=
dispatcherPollAll
(
dispatcher
);
dispatcherExecute
(
statements
);
taosArrayDestroy
(
&
statements
);
pthread_cond_broadcast
(
&
dispatcher
->
notFull
);
}
pthread_mutex_unlock
(
&
dispatcher
->
mutex
);
return
currentSiz
e
;
return
tru
e
;
}
void
dispatcherExecute
(
SArray
*
statements
)
{
...
...
@@ -339,11 +338,11 @@ SAsyncBulkWriteDispatcher* createAsyncBulkWriteDispatcher(int32_t batchSize, int
return
NULL
;
}
dispatcher
->
currentSize
=
0
;
dispatcher
->
batchSize
=
batchSize
;
dispatcher
->
timeoutMs
=
timeoutMs
;
atomic_store_32
(
&
dispatcher
->
bufferSize
,
0
);
atomic_store_32
(
&
dispatcher
->
currentSize
,
0
);
atomic_store_8
(
&
dispatcher
->
shutdown
,
false
);
atomic_store_8
(
&
dispatcher
->
exclusive
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录