mirror of
https://gitee.com/TarsCloud/TarsCpp.git
synced 2024-12-22 22:16:38 +08:00
添加微秒获取接口
This commit is contained in:
parent
54f356bbf7
commit
83d6195935
@ -28,6 +28,7 @@ namespace tars
|
||||
{
|
||||
#define TNOW TC_TimeProvider::getInstance()->getNow()
|
||||
#define TNOWMS TC_TimeProvider::getInstance()->getNowMs()
|
||||
#define TNOWUS TC_TimeProvider::getInstance()->getNowUs()
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
/**
|
||||
@ -95,6 +96,14 @@ public:
|
||||
*/
|
||||
uint64_t getNowMs();
|
||||
|
||||
/**
|
||||
* @brief 获取us时间.
|
||||
*
|
||||
* @para timeval
|
||||
* @return void
|
||||
*/
|
||||
uint64_t getNowUs();
|
||||
|
||||
protected:
|
||||
static TC_TimeProvider *g_tp;
|
||||
|
||||
|
@ -114,6 +114,14 @@ uint64_t TC_TimeProvider::getNowMs()
|
||||
return tv.tv_sec * (int64_t)1000 + tv.tv_usec / 1000;
|
||||
}
|
||||
|
||||
uint64_t TC_TimeProvider::getNowUs()
|
||||
{
|
||||
struct timeval tv;
|
||||
getNow(&tv);
|
||||
|
||||
return tv.tv_sec * (int64_t)1000000 + tv.tv_usec;
|
||||
}
|
||||
|
||||
void TC_TimeProvider::run()
|
||||
{
|
||||
memset(_tsc, 0x00, sizeof(_tsc));
|
||||
|
Loading…
Reference in New Issue
Block a user