Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
buyaopa
TDengine
提交
5ecda58f
T
TDengine
项目概览
buyaopa
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5ecda58f
编写于
6月 23, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 23, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2424 from taosdata/feature/2.0tsdb
Feature/2.0tsdb
上级
4838d85f
8acc4b0b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
120 addition
and
0 deletion
+120
-0
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+2
-0
src/tsdb/src/tsdbBuffer.c
src/tsdb/src/tsdbBuffer.c
+2
-0
src/util/inc/trwlatch.h
src/util/inc/trwlatch.h
+36
-0
src/util/src/trwlatch.c
src/util/src/trwlatch.c
+80
-0
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
5ecda58f
...
...
@@ -25,6 +25,7 @@
#include "tsdb.h"
#include "tskiplist.h"
#include "tutil.h"
#include "trwlatch.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -59,6 +60,7 @@ typedef struct STable {
TSKEY
lastKey
;
// lastkey inserted in this table, initialized as 0, TODO: make a structure
char
*
sql
;
void
*
cqhandle
;
SRWLatch
latch
;
// TODO: implementa latch functions
T_REF_DECLARE
();
}
STable
;
...
...
src/tsdb/src/tsdbBuffer.c
浏览文件 @
5ecda58f
...
...
@@ -120,7 +120,9 @@ SListNode *tsdbAllocBufBlockFromPool(STsdbRepo *pRepo) {
STsdbBufPool
*
pBufPool
=
pRepo
->
pPool
;
while
(
POOL_IS_EMPTY
(
pBufPool
))
{
pRepo
->
repoLocked
=
false
;
pthread_cond_wait
(
&
(
pBufPool
->
poolNotEmpty
),
&
(
pRepo
->
mutex
));
pRepo
->
repoLocked
=
true
;
}
SListNode
*
pNode
=
tdListPopHead
(
pBufPool
->
bufBlockList
);
...
...
src/util/inc/trwlatch.h
0 → 100644
浏览文件 @
5ecda58f
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TD_RWLATCH_H__
#define __TD_RWLATCH_H__
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
typedef
int32_t
SRWLatch
;
void
taosInitRWLatch
(
SRWLatch
*
pLatch
);
void
taosWLockLatch
(
SRWLatch
*
pLatch
);
void
taosWUnLockLatch
(
SRWLatch
*
pLatch
);
void
taosRLockLatch
(
SRWLatch
*
pLatch
);
void
taosRUnLockLatch
(
SRWLatch
*
pLatch
);
#ifdef __cplusplus
}
#endif
#endif
src/util/src/trwlatch.c
0 → 100644
浏览文件 @
5ecda58f
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// #define _GNU_SOURCE
// #include <pthread.h>
#include "trwlatch.h"
#include "os.h"
#define TD_RWLATCH_WRITE_FLAG 0x40000000
void
taosInitRWLatch
(
SRWLatch
*
pLatch
)
{
*
pLatch
=
0
;
}
void
taosWLockLatch
(
SRWLatch
*
pLatch
)
{
SRWLatch
oLatch
,
nLatch
;
int
nLoops
=
0
;
// Set write flag
while
(
1
)
{
oLatch
=
atomic_load_32
(
pLatch
);
if
(
oLatch
&
TD_RWLATCH_WRITE_FLAG
)
{
nLoops
++
;
if
(
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
continue
;
}
nLatch
=
oLatch
|
TD_RWLATCH_WRITE_FLAG
;
if
(
atomic_val_compare_exchange_32
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
}
// wait for all reads end
nLoops
=
0
;
while
(
1
)
{
oLatch
=
atomic_load_32
(
pLatch
);
if
(
oLatch
==
TD_RWLATCH_WRITE_FLAG
)
break
;
nLoops
++
;
if
(
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
}
}
void
taosWUnLockLatch
(
SRWLatch
*
pLatch
)
{
atomic_store_32
(
pLatch
,
0
);
}
void
taosRLockLatch
(
SRWLatch
*
pLatch
)
{
SRWLatch
oLatch
,
nLatch
;
int
nLoops
=
0
;
while
(
1
)
{
oLatch
=
atomic_load_32
(
pLatch
);
if
(
oLatch
&
TD_RWLATCH_WRITE_FLAG
)
{
nLoops
++
;
if
(
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
continue
;
}
nLatch
=
oLatch
+
1
;
if
(
atomic_val_compare_exchange_32
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
}
}
void
taosRUnLockLatch
(
SRWLatch
*
pLatch
)
{
atomic_fetch_sub_32
(
pLatch
,
1
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录