Replaced dependencies on ace/OS_NS_time.h
This commit is contained in:
@@ -84,8 +84,6 @@
|
||||
#include "Threading/LockedQueue.h"
|
||||
#include "Threading/Threading.h"
|
||||
|
||||
#include <ace/OS_NS_time.h>
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
# include <ace/config-all.h>
|
||||
// XP winver - needed to compile with standard leak check in MemoryLeaks.h
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
#include "Appender.h"
|
||||
#include "Common.h"
|
||||
#include "Util.h"
|
||||
|
||||
std::string LogMessage::getTimeStr(time_t time)
|
||||
{
|
||||
tm aTm;
|
||||
ACE_OS::localtime_r(&time, &aTm);
|
||||
tm aTm = localtime_r(time);
|
||||
char buf[20];
|
||||
snprintf(buf, 20, "%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year+1900, aTm.tm_mon+1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
|
||||
return std::string(buf);
|
||||
|
||||
@@ -283,9 +283,10 @@ void Log::write(LogMessage* msg)
|
||||
|
||||
std::string Log::GetTimestampStr()
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
tm aTm;
|
||||
ACE_OS::localtime_r(&t, &aTm);
|
||||
time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||
|
||||
std::tm aTm = localtime_r(tt);
|
||||
|
||||
// YYYY year
|
||||
// MM month (2 digits 01-12)
|
||||
// DD day (2 digits 01-31)
|
||||
|
||||
+115
-113
@@ -19,13 +19,15 @@
|
||||
#ifndef TRINITY_TIMER_H
|
||||
#define TRINITY_TIMER_H
|
||||
|
||||
#include "ace/OS_NS_sys_time.h"
|
||||
#include "Common.h"
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
inline uint32 getMSTime()
|
||||
{
|
||||
static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday();
|
||||
return (ACE_OS::gettimeofday() - ApplicationStartTime).msec();
|
||||
static const system_clock::time_point ApplicationStartTime = system_clock::now();
|
||||
|
||||
return duration_cast<milliseconds>(system_clock::now() - ApplicationStartTime).count();
|
||||
}
|
||||
|
||||
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
|
||||
@@ -44,158 +46,158 @@ inline uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
|
||||
|
||||
struct IntervalTimer
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
IntervalTimer()
|
||||
: _interval(0), _current(0)
|
||||
{
|
||||
}
|
||||
IntervalTimer()
|
||||
: _interval(0), _current(0)
|
||||
{
|
||||
}
|
||||
|
||||
void Update(time_t diff)
|
||||
{
|
||||
_current += diff;
|
||||
if (_current < 0)
|
||||
_current = 0;
|
||||
}
|
||||
void Update(time_t diff)
|
||||
{
|
||||
_current += diff;
|
||||
if (_current < 0)
|
||||
_current = 0;
|
||||
}
|
||||
|
||||
bool Passed()
|
||||
{
|
||||
return _current >= _interval;
|
||||
}
|
||||
bool Passed()
|
||||
{
|
||||
return _current >= _interval;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
if (_current >= _interval)
|
||||
_current %= _interval;
|
||||
}
|
||||
void Reset()
|
||||
{
|
||||
if (_current >= _interval)
|
||||
_current %= _interval;
|
||||
}
|
||||
|
||||
void SetCurrent(time_t current)
|
||||
{
|
||||
_current = current;
|
||||
}
|
||||
void SetCurrent(time_t current)
|
||||
{
|
||||
_current = current;
|
||||
}
|
||||
|
||||
void SetInterval(time_t interval)
|
||||
{
|
||||
_interval = interval;
|
||||
}
|
||||
void SetInterval(time_t interval)
|
||||
{
|
||||
_interval = interval;
|
||||
}
|
||||
|
||||
time_t GetInterval() const
|
||||
{
|
||||
return _interval;
|
||||
}
|
||||
time_t GetInterval() const
|
||||
{
|
||||
return _interval;
|
||||
}
|
||||
|
||||
time_t GetCurrent() const
|
||||
{
|
||||
return _current;
|
||||
}
|
||||
time_t GetCurrent() const
|
||||
{
|
||||
return _current;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
time_t _interval;
|
||||
time_t _current;
|
||||
time_t _interval;
|
||||
time_t _current;
|
||||
};
|
||||
|
||||
struct TimeTracker
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
TimeTracker(time_t expiry)
|
||||
: i_expiryTime(expiry)
|
||||
{
|
||||
}
|
||||
TimeTracker(time_t expiry)
|
||||
: i_expiryTime(expiry)
|
||||
{
|
||||
}
|
||||
|
||||
void Update(time_t diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
}
|
||||
void Update(time_t diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
}
|
||||
|
||||
bool Passed() const
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
}
|
||||
bool Passed() const
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
}
|
||||
|
||||
void Reset(time_t interval)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
}
|
||||
void Reset(time_t interval)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
}
|
||||
|
||||
time_t GetExpiry() const
|
||||
{
|
||||
return i_expiryTime;
|
||||
}
|
||||
time_t GetExpiry() const
|
||||
{
|
||||
return i_expiryTime;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
time_t i_expiryTime;
|
||||
time_t i_expiryTime;
|
||||
};
|
||||
|
||||
struct TimeTrackerSmall
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
TimeTrackerSmall(uint32 expiry = 0)
|
||||
: i_expiryTime(expiry)
|
||||
{
|
||||
}
|
||||
TimeTrackerSmall(uint32 expiry = 0)
|
||||
: i_expiryTime(expiry)
|
||||
{
|
||||
}
|
||||
|
||||
void Update(int32 diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
}
|
||||
void Update(int32 diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
}
|
||||
|
||||
bool Passed() const
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
}
|
||||
bool Passed() const
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
}
|
||||
|
||||
void Reset(uint32 interval)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
}
|
||||
void Reset(uint32 interval)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
}
|
||||
|
||||
int32 GetExpiry() const
|
||||
{
|
||||
return i_expiryTime;
|
||||
}
|
||||
int32 GetExpiry() const
|
||||
{
|
||||
return i_expiryTime;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
int32 i_expiryTime;
|
||||
int32 i_expiryTime;
|
||||
};
|
||||
|
||||
struct PeriodicTimer
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
PeriodicTimer(int32 period, int32 start_time)
|
||||
: i_period(period), i_expireTime(start_time)
|
||||
{
|
||||
}
|
||||
PeriodicTimer(int32 period, int32 start_time)
|
||||
: i_period(period), i_expireTime(start_time)
|
||||
{
|
||||
}
|
||||
|
||||
bool Update(const uint32 diff)
|
||||
{
|
||||
if ((i_expireTime -= diff) > 0)
|
||||
return false;
|
||||
bool Update(const uint32 diff)
|
||||
{
|
||||
if ((i_expireTime -= diff) > 0)
|
||||
return false;
|
||||
|
||||
i_expireTime += i_period > int32(diff) ? i_period : diff;
|
||||
return true;
|
||||
}
|
||||
i_expireTime += i_period > int32(diff) ? i_period : diff;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetPeriodic(int32 period, int32 start_time)
|
||||
{
|
||||
i_expireTime = start_time;
|
||||
i_period = period;
|
||||
}
|
||||
void SetPeriodic(int32 period, int32 start_time)
|
||||
{
|
||||
i_expireTime = start_time;
|
||||
i_period = period;
|
||||
}
|
||||
|
||||
// Tracker interface
|
||||
void TUpdate(int32 diff) { i_expireTime -= diff; }
|
||||
bool TPassed() const { return i_expireTime <= 0; }
|
||||
void TReset(int32 diff, int32 period) { i_expireTime += period > diff ? period : diff; }
|
||||
// Tracker interface
|
||||
void TUpdate(int32 diff) { i_expireTime -= diff; }
|
||||
bool TPassed() const { return i_expireTime <= 0; }
|
||||
void TReset(int32 diff, int32 period) { i_expireTime += period > diff ? period : diff; }
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
int32 i_period;
|
||||
int32 i_expireTime;
|
||||
int32 i_period;
|
||||
int32 i_expireTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -127,6 +127,18 @@ void stripLineInvisibleChars(std::string &str)
|
||||
|
||||
}
|
||||
|
||||
std::tm localtime_r(const time_t& time)
|
||||
{
|
||||
std::tm tm_snapshot;
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
|
||||
localtime_s(&tm_snapshot, &time);
|
||||
#else
|
||||
localtime_r(&time, &tm_snapshot); // POSIX
|
||||
#endif
|
||||
return tm_snapshot;
|
||||
}
|
||||
|
||||
|
||||
std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
|
||||
{
|
||||
uint64 secs = timeInSecs % MINUTE;
|
||||
@@ -215,8 +227,7 @@ uint32 TimeStringToSecs(const std::string& timestring)
|
||||
|
||||
std::string TimeToTimestampStr(time_t t)
|
||||
{
|
||||
tm aTm;
|
||||
ACE_OS::localtime_r(&t, &aTm);
|
||||
tm aTm = localtime_r(t);
|
||||
// YYYY year
|
||||
// MM month (2 digits 01-12)
|
||||
// DD day (2 digits 01-31)
|
||||
|
||||
@@ -70,6 +70,8 @@ void stripLineInvisibleChars(std::string &src);
|
||||
|
||||
int32 MoneyStringToMoney(const std::string& moneyString);
|
||||
|
||||
std::tm localtime_r(const time_t& time);
|
||||
|
||||
std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hoursOnly = false);
|
||||
uint32 TimeStringToSecs(const std::string& timestring);
|
||||
std::string TimeToTimestampStr(time_t t);
|
||||
|
||||
Reference in New Issue
Block a user