Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
51943b6f
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
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看板
未验证
提交
51943b6f
编写于
11月 08, 2019
作者:
S
slguan
提交者:
GitHub
11月 08, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #684 from taosdata/feature/newtimer
new timer implementation
上级
1c3fcabe
82ce093a
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
592 addition
and
484 deletion
+592
-484
src/inc/ttimer.h
src/inc/ttimer.h
+16
-15
src/os/darwin/inc/os.h
src/os/darwin/inc/os.h
+34
-0
src/os/linux/inc/os.h
src/os/linux/inc/os.h
+29
-0
src/os/windows/inc/os.h
src/os/windows/inc/os.h
+70
-6
src/os/windows/src/twindows.c
src/os/windows/src/twindows.c
+13
-17
src/util/src/ttimer.c
src/util/src/ttimer.c
+430
-446
未找到文件。
src/inc/ttimer.h
浏览文件 @
51943b6f
...
...
@@ -21,40 +21,41 @@ extern "C" {
#endif
typedef
void
*
tmr_h
;
typedef
void
(
*
TAOS_TMR_CALLBACK
)(
void
*
,
void
*
);
extern
uint32_t
tmrDebugFlag
;
extern
int
taosTmrThreads
;
#define tmrError(...) \
if (tmrDebugFlag & DEBUG_ERROR) {
\
do { if (tmrDebugFlag & DEBUG_ERROR) {
\
tprintf("ERROR TMR ", tmrDebugFlag, __VA_ARGS__); \
}
} } while(0)
#define tmrWarn(...) \
if (tmrDebugFlag & DEBUG_WARN) {
\
do { if (tmrDebugFlag & DEBUG_WARN) {
\
tprintf("WARN TMR ", tmrDebugFlag, __VA_ARGS__); \
}
} } while(0)
#define tmrTrace(...) \
if (tmrDebugFlag & DEBUG_TRACE) {
\
do { if (tmrDebugFlag & DEBUG_TRACE) {
\
tprintf("TMR ", tmrDebugFlag, __VA_ARGS__); \
}
}
} while(0)
#define MAX_NUM_OF_TMRCTL
51
2
#define MAX_NUM_OF_TMRCTL
3
2
#define MSECONDS_PER_TICK 5
void
*
taosTmrInit
(
int
maxTmr
,
int
resoultion
,
int
longest
,
char
*
label
);
void
*
taosTmrInit
(
int
maxTmr
,
int
resoultion
,
int
longest
,
c
onst
c
har
*
label
);
tmr_h
taosTmrStart
(
void
(
*
fp
)(
void
*
,
void
*
),
int
mseconds
,
void
*
param1
,
void
*
handle
);
tmr_h
taosTmrStart
(
TAOS_TMR_CALLBACK
fp
,
int
mseconds
,
void
*
param
,
void
*
handle
);
void
taosTmrStop
(
tmr_h
tmrId
);
bool
taosTmrStop
(
tmr_h
tmrId
);
void
taosTmrStopA
(
tmr_h
*
timerId
);
bool
taosTmrStopA
(
tmr_h
*
timerId
);
void
taosTmrReset
(
void
(
*
fp
)(
void
*
,
void
*
),
int
mseconds
,
void
*
param1
,
void
*
handle
,
tmr_h
*
pTmrId
);
bool
taosTmrReset
(
TAOS_TMR_CALLBACK
fp
,
int
mseconds
,
void
*
param
,
void
*
handle
,
tmr_h
*
pTmrId
);
void
taosTmrCleanUp
(
void
*
handle
);
void
taosTmrList
(
void
*
handle
);
#ifdef __cplusplus
}
#endif
...
...
src/os/darwin/inc/os.h
浏览文件 @
51943b6f
...
...
@@ -55,10 +55,44 @@
#define taosWriteSocket(fd, buf, len) write(fd, buf, len)
#define taosReadSocket(fd, buf, len) read(fd, buf, len)
#define atomic_load_8(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_16(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_32(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_64(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_ptr(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_store_8(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_16(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_32(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_64(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_ptr(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_8(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_16(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_32(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_64(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_ptr(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
// TODO: update prefix of below macros to 'atomic' as '__' is reserved by compiler
// and GCC suggest new code to use '__atomic' builtins to replace '__sync' builtins.
#define __sync_val_compare_and_swap_64 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_32 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_16 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_8 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_ptr __sync_val_compare_and_swap
#define __sync_add_and_fetch_64 __sync_add_and_fetch
#define __sync_add_and_fetch_32 __sync_add_and_fetch
#define __sync_add_and_fetch_16 __sync_add_and_fetch
#define __sync_add_and_fetch_8 __sync_add_and_fetch
#define __sync_add_and_fetch_ptr __sync_add_and_fetch
#define __sync_sub_and_fetch_64 __sync_sub_and_fetch
#define __sync_sub_and_fetch_32 __sync_sub_and_fetch
#define __sync_sub_and_fetch_16 __sync_sub_and_fetch
#define __sync_sub_and_fetch_8 __sync_sub_and_fetch
#define __sync_sub_and_fetch_ptr __sync_sub_and_fetch
int32_t
__sync_val_load_32
(
int32_t
*
ptr
);
void
__sync_val_restore_32
(
int32_t
*
ptr
,
int32_t
newval
);
...
...
src/os/linux/inc/os.h
浏览文件 @
51943b6f
...
...
@@ -71,14 +71,43 @@ extern "C" {
#define taosWriteSocket(fd, buf, len) write(fd, buf, len)
#define taosReadSocket(fd, buf, len) read(fd, buf, len)
#define atomic_load_8(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_16(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_32(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_64(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_load_ptr(ptr) __atomic_load_n((ptr), __ATOMIC_SEQ_CST)
#define atomic_store_8(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_16(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_32(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_64(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_store_ptr(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_8(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_16(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_32(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_64(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
#define atomic_exchange_ptr(ptr, val) __atomic_exchange_n((ptr), (val), __ATOMIC_SEQ_CST)
// TODO: update prefix of below macros to 'atomic' as '__' is reserved by compiler
// and GCC suggest new code to use '__atomic' builtins to replace '__sync' builtins.
#define __sync_val_compare_and_swap_64 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_32 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_16 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_8 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_ptr __sync_val_compare_and_swap
#define __sync_add_and_fetch_64 __sync_add_and_fetch
#define __sync_add_and_fetch_32 __sync_add_and_fetch
#define __sync_add_and_fetch_16 __sync_add_and_fetch
#define __sync_add_and_fetch_8 __sync_add_and_fetch
#define __sync_add_and_fetch_ptr __sync_add_and_fetch
#define __sync_sub_and_fetch_64 __sync_sub_and_fetch
#define __sync_sub_and_fetch_32 __sync_sub_and_fetch
#define __sync_sub_and_fetch_16 __sync_sub_and_fetch
#define __sync_sub_and_fetch_8 __sync_sub_and_fetch
#define __sync_sub_and_fetch_ptr __sync_sub_and_fetch
int32_t
__sync_val_load_32
(
int32_t
*
ptr
);
void
__sync_val_restore_32
(
int32_t
*
ptr
,
int32_t
newval
);
...
...
src/os/windows/inc/os.h
浏览文件 @
51943b6f
...
...
@@ -29,6 +29,7 @@
#include <math.h>
#include <string.h>
#include <assert.h>
#include <intrin.h>
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -78,12 +79,75 @@ extern "C" {
#define taosWriteSocket(fd, buf, len) send(fd, buf, len, 0)
#define taosReadSocket(fd, buf, len) recv(fd, buf, len, 0)
int32_t
__sync_val_compare_and_swap_32
(
int32_t
*
ptr
,
int32_t
oldval
,
int32_t
newval
);
int32_t
__sync_add_and_fetch_32
(
int32_t
*
ptr
,
int32_t
val
);
int32_t
__sync_sub_and_fetch_32
(
int32_t
*
ptr
,
int32_t
val
);
int64_t
__sync_val_compare_and_swap_64
(
int64_t
*
ptr
,
int64_t
oldval
,
int64_t
newval
);
int64_t
__sync_add_and_fetch_64
(
int64_t
*
ptr
,
int64_t
val
);
int64_t
__sync_sub_and_fetch_64
(
int64_t
*
ptr
,
int64_t
val
);
#if defined(_M_ARM) || defined(_M_ARM64)
#define atomic_load_8(ptr) __iso_volatile_load8((const volatile __int8*)(ptr))
#define atomic_load_16(ptr) __iso_volatile_load16((const volatile __int16*)(ptr))
#define atomic_load_32(ptr) __iso_volatile_load32((const volatile __int32*)(ptr))
#define atomic_load_64(ptr) __iso_volatile_load64((const volatile __int64*)(ptr))
#define atomic_store_8(ptr, val) __iso_volatile_store8((volatile __int8*)(ptr), (__int8)(val))
#define atomic_store_16(ptr, val) __iso_volatile_store16((volatile __int16*)(ptr), (__int16)(val))
#define atomic_store_32(ptr, val) __iso_volatile_store32((volatile __int32*)(ptr), (__int32)(val))
#define atomic_store_64(ptr, val) __iso_volatile_store64((volatile __int64*)(ptr), (__int64)(val))
#ifdef _M_ARM64
#define atomic_load_ptr atomic_load_64
#define atomic_store_ptr atomic_store_64
#else
#define atomic_load_ptr atomic_load_32
#define atomic_store_ptr atomic_store_32
#endif
#else
#define atomic_load_8(ptr) (*(char volatile*)(ptr))
#define atomic_load_16(ptr) (*(short volatile*)(ptr))
#define atomic_load_32(ptr) (*(long volatile*)(ptr))
#define atomic_load_64(ptr) (*(__int64 volatile*)(ptr))
#define atomic_load_ptr(ptr) (*(void* volatile*)(ptr))
#define atomic_store_8(ptr, val) ((*(char volatile*)(ptr)) = (char)(val))
#define atomic_store_16(ptr, val) ((*(short volatile*)(ptr)) = (short)(val))
#define atomic_store_32(ptr, val) ((*(long volatile*)(ptr)) = (long)(val))
#define atomic_store_64(ptr, val) ((*(__int64 volatile*)(ptr)) = (__int64)(val))
#define atomic_store_ptr(ptr, val) ((*(void* volatile*)(ptr)) = (void*)(val))
#endif
#define atomic_exchange_8(ptr, val) _InterlockedExchange8((char volatile*)(ptr), (char)(val))
#define atomic_exchange_16(ptr, val) _InterlockedExchange16((short volatile*)(ptr), (short)(val))
#define atomic_exchange_32(ptr, val) _InterlockedExchange((long volatile*)(ptr), (long)(val))
#define atomic_exchange_64(ptr, val) _InterlockedExchange64((__int64 volatile*)(ptr), (__int64)(val))
#define atomic_exchange_ptr(ptr, val) _InterlockedExchangePointer((void* volatile*)(ptr), (void*)(val))
#define __sync_val_compare_and_swap_8(ptr, oldval, newval) _InterlockedCompareExchange8((char volatile*)(ptr), (char)(newval), (char)(oldval))
#define __sync_val_compare_and_swap_16(ptr, oldval, newval) _InterlockedCompareExchange16((short volatile*)(ptr), (short)(newval), (short)(oldval))
#define __sync_val_compare_and_swap_32(ptr, oldval, newval) _InterlockedCompareExchange((long volatile*)(ptr), (long)(newval), (long)(oldval))
#define __sync_val_compare_and_swap_64(ptr, oldval, newval) _InterlockedCompareExchange64((__int64 volatile*)(ptr), (__int64)(newval), (__int64)(oldval))
#define __sync_val_compare_and_swap_ptr(ptr, oldval, newval) _InterlockedCompareExchangePointer((void* volatile*)(ptr), (void*)(newval), (void*)(oldval))
char
interlocked_add_8
(
char
volatile
*
ptr
,
char
val
);
short
interlocked_add_16
(
short
volatile
*
ptr
,
short
val
);
long
interlocked_add_32
(
long
volatile
*
ptr
,
long
val
);
__int64
interlocked_add_64
(
__int64
volatile
*
ptr
,
__int64
val
);
#define __sync_add_and_fetch_8(ptr, val) interlocked_add_8((char volatile*)(ptr), (char)(val))
#define __sync_add_and_fetch_16(ptr, val) interlocked_add_16((short volatile*)(ptr), (short)(val))
#define __sync_add_and_fetch_32(ptr, val) interlocked_add_32((long volatile*)(ptr), (long)(val))
#define __sync_add_and_fetch_64(ptr, val) interlocked_add_64((__int64 volatile*)(ptr), (__int64)(val))
#ifdef _WIN64
#define __sync_add_and_fetch_ptr __sync_add_and_fetch_64
#else
#define __sync_add_and_fetch_ptr __sync_add_and_fetch_32
#endif
#define __sync_sub_and_fetch_8(ptr, val) __sync_add_and_fetch_8((ptr), -(val))
#define __sync_sub_and_fetch_16(ptr, val) __sync_add_and_fetch_16((ptr), -(val))
#define __sync_sub_and_fetch_32(ptr, val) __sync_add_and_fetch_32((ptr), -(val))
#define __sync_sub_and_fetch_64(ptr, val) __sync_add_and_fetch_64((ptr), -(val))
#define __sync_sub_and_fetch_ptr(ptr, val) __sync_add_and_fetch_ptr((ptr), -(val))
int32_t
__sync_val_load_32
(
int32_t
*
ptr
);
void
__sync_val_restore_32
(
int32_t
*
ptr
,
int32_t
newval
);
...
...
src/os/windows/src/twindows.c
浏览文件 @
51943b6f
...
...
@@ -43,8 +43,11 @@ void taosResetPthread(pthread_t *thread) {
}
int64_t
taosGetPthreadId
()
{
pthread_t
id
=
pthread_self
();
return
(
int64_t
)
id
.
p
;
#ifdef PTW32_VERSION
return
pthread_getw32threadid_np
(
pthread_self
());
#else
return
(
int64_t
)
pthread_self
();
#endif
}
int
taosSetSockOpt
(
int
socketfd
,
int
level
,
int
optname
,
void
*
optval
,
int
optlen
)
{
...
...
@@ -63,28 +66,21 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle
return
setsockopt
(
socketfd
,
level
,
optname
,
optval
,
optlen
);
}
int32_t
__sync_val_compare_and_swap_32
(
int32_t
*
ptr
,
int32_t
oldval
,
int32_t
newval
)
{
return
InterlockedCompareExchange
(
ptr
,
newval
,
oldval
);
}
int32_t
__sync_add_and_fetch_32
(
int32_t
*
ptr
,
int32_t
val
)
{
return
InterlockedAdd
(
ptr
,
val
);
}
int32_t
__sync_sub_and_fetch_32
(
int32_t
*
ptr
,
int32_t
val
)
{
return
InterlockedAdd
(
ptr
,
-
val
)
;
char
interlocked_add_8
(
char
volatile
*
ptr
,
char
val
)
{
return
_InterlockedExchangeAdd8
(
ptr
,
val
)
+
val
;
}
int64_t
__sync_val_compare_and_swap_64
(
int64_t
*
ptr
,
int64_t
oldval
,
int64_t
new
val
)
{
return
InterlockedCompareExchange64
(
ptr
,
newval
,
oldval
)
;
short
interlocked_add_16
(
short
volatile
*
ptr
,
short
val
)
{
return
_InterlockedExchangeAdd16
(
ptr
,
val
)
+
val
;
}
int64_t
__sync_add_and_fetch_64
(
int64_t
*
ptr
,
int64_t
val
)
{
return
InterlockedAdd64
(
ptr
,
val
)
;
long
interlocked_add_32
(
long
volatile
*
ptr
,
long
val
)
{
return
_InterlockedExchangeAdd
(
ptr
,
val
)
+
val
;
}
int64_t
__sync_sub_and_fetch_64
(
int64_t
*
ptr
,
int64_t
val
)
{
return
InterlockedAdd64
(
ptr
,
-
val
)
;
__int64
interlocked_add_64
(
__int64
volatile
*
ptr
,
__int64
val
)
{
return
_InterlockedExchangeAdd64
(
ptr
,
val
)
+
val
;
}
int32_t
__sync_val_load_32
(
int32_t
*
ptr
)
{
...
...
src/util/src/ttimer.c
浏览文件 @
51943b6f
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录