ttimer.h 1.8 KB
Newer Older
H
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * 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 TDENGINE_TTIMER_H
#define TDENGINE_TTIMER_H

#ifdef __cplusplus
extern "C" {
#endif

typedef void *tmr_h;
weixin_48148422's avatar
weixin_48148422 已提交
24
typedef void (*TAOS_TMR_CALLBACK)(void *, void *);
H
hzcheng 已提交
25

26
extern uint32_t tmrDebugFlag;
weixin_48148422's avatar
weixin_48148422 已提交
27
extern int      taosTmrThreads;
H
hzcheng 已提交
28

S
slguan 已提交
29
#define tmrError(...)                                 \
weixin_48148422's avatar
weixin_48148422 已提交
30
  do { if (tmrDebugFlag & DEBUG_ERROR) {              \
S
slguan 已提交
31
    tprintf("ERROR TMR ", tmrDebugFlag, __VA_ARGS__); \
weixin_48148422's avatar
weixin_48148422 已提交
32 33
  } } while(0)

S
slguan 已提交
34
#define tmrWarn(...)                                  \
weixin_48148422's avatar
weixin_48148422 已提交
35
  do { if (tmrDebugFlag & DEBUG_WARN) {               \
S
slguan 已提交
36
    tprintf("WARN  TMR ", tmrDebugFlag, __VA_ARGS__); \
weixin_48148422's avatar
weixin_48148422 已提交
37 38
  } } while(0)

S
slguan 已提交
39
#define tmrTrace(...)                           \
weixin_48148422's avatar
weixin_48148422 已提交
40
  do { if (tmrDebugFlag & DEBUG_TRACE) {        \
S
slguan 已提交
41
    tprintf("TMR ", tmrDebugFlag, __VA_ARGS__); \
weixin_48148422's avatar
weixin_48148422 已提交
42
  } } while(0)
S
slguan 已提交
43

weixin_48148422's avatar
weixin_48148422 已提交
44
#define MAX_NUM_OF_TMRCTL 32
S
slguan 已提交
45 46
#define MSECONDS_PER_TICK 5

weixin_48148422's avatar
weixin_48148422 已提交
47
void *taosTmrInit(int maxTmr, int resoultion, int longest, const char *label);
H
hzcheng 已提交
48

weixin_48148422's avatar
weixin_48148422 已提交
49
tmr_h taosTmrStart(TAOS_TMR_CALLBACK fp, int mseconds, void *param, void *handle);
H
hzcheng 已提交
50

weixin_48148422's avatar
weixin_48148422 已提交
51
bool taosTmrStop(tmr_h tmrId);
S
slguan 已提交
52

weixin_48148422's avatar
weixin_48148422 已提交
53
bool taosTmrStopA(tmr_h *timerId);
H
hzcheng 已提交
54

weixin_48148422's avatar
weixin_48148422 已提交
55
bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void *param, void *handle, tmr_h *pTmrId);
H
hzcheng 已提交
56 57 58 59 60 61 62 63

void taosTmrCleanUp(void *handle);

#ifdef __cplusplus
}
#endif

#endif  // TDENGINE_TTIMER_H