-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.h
67 lines (54 loc) · 1.39 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __COMMON_H_
#define __COMMON_H_
#include <stdint.h>
#include <sys/time.h>
namespace NSQTOOL
{
enum EConnectKeepType
{
ESHORTCONNECT = 0,
ELONGCONNECT = 1,
};
extern int g_iShortConnectTimeout ; //300ms
extern int g_iLongConnectTimeout ; //30s
extern int g_iCmdQueueLength;
using namespace std;
//命令处理时间
extern int g_iCmdProcessTime;
//线程死锁时间
extern int g_iThreadDeadLockTime;
int64_t GetTvToMsc(const struct timeval *tv);
//获取当前时间与参数的差值,单位ms
int64_t GetIntervalNow(const struct timeval *pTimeval);
enum EInternalCmdType
{
STOP_TYPE = -1,
TCP_CONNECT_TYPE = -2,
TCP_LISTEN_ADD_TYPE = -3,
TCP_LISTEN_DEL_TYPE = -4,
TCP_LISTEN_ACCEPT_TYPE = -11,
TCP_DEL_TYPE = -5,
TCP_ADD_TYPE = -6,
TCP_SEND_TYPE = -7,
TCP_READ_TYPE = -8,
TIMER_ADD_TYPE = -9,
TIMER_DEL_TYPE = -10
};
enum EInternalThreadType
{
NET_THREAD_TYPE = -1,
LISTEN_THREAD_TYPE = -2,
TIMER_THREAD_TYPE = -3,
NSQ_THREAD_TYPE = -4,
};
enum LOG_LEVEL
{
LOG_DEBUG = -3,
LOG_ERROR = -2
};
typedef void (*LOGCALLBACK)(int, const char *pLogMsg);
extern void NsqLogPrintf(int iLogLevel, const char *pFormat, ...);
extern LOGCALLBACK g_pLogFunc;
extern int g_iLogLevel;
};
#endif