@@ -4,6 +4,7 @@
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -221,7 +222,6 @@ static inline uint64_t GetSysCurrentTime()
|
||||
gettimeofday(&t, NULL);
|
||||
return (uint64_t)(t.tv_sec * 1000 + t.tv_usec / 1000);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static inline uint64_t GetCurrentTimeTick(snowflake *flake)
|
||||
@@ -232,9 +232,21 @@ static inline uint64_t GetCurrentTimeTick(snowflake* flake)
|
||||
static inline uint64_t GetNextTimeTick(snowflake *flake)
|
||||
{
|
||||
uint64_t tempTimeTicker = GetCurrentTimeTick(flake);
|
||||
while (tempTimeTicker <= flake->_LastTimeTick)
|
||||
struct timespec delay;
|
||||
delay.tv_sec = 0;
|
||||
delay.tv_nsec = 500000;
|
||||
while (1)
|
||||
{
|
||||
tempTimeTicker = GetCurrentTimeTick(flake);
|
||||
if (tempTimeTicker > flake->_LastTimeTick)
|
||||
{
|
||||
break;
|
||||
}
|
||||
#ifdef WIN32
|
||||
SwitchToThread();
|
||||
#else
|
||||
nanosleep(&delay, NULL);
|
||||
#endif
|
||||
}
|
||||
return tempTimeTicker;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user