
#include <libclientserver.h>

RateLimit::RateLimit()
{
	m_last = {0, 0};
}

RateLimit::~RateLimit()
{

}

void RateLimit::SetTimeout(const struct timespec *tv)
{
	memcpy(&m_timeout, tv, sizeof(*tv));
}

bool RateLimit::Check()
{
	struct timespec now;
	struct timespec when;
	Time::MonoTonic(&now);
	Time::Add(&now, &m_timeout, &when);

	if (Time::IsGreater(&now, &when))
	{
		memcpy(&m_last, &now, sizeof(now));
		return true;
	}
	return false;

}



#include <libclientserver.h>

RateLimit::RateLimit()
{
	m_last.tv_sec = 0;
	m_last.tv_nsec = 0;
}

RateLimit::~RateLimit()
{

}

void RateLimit::SetTimeout(const struct timespec *tv)
{
	memcpy(&m_timeout, tv, sizeof(*tv));
}

bool RateLimit::Check()
{
	struct timespec now;
	struct timespec when;
	Time::MonoTonic(&now);
	Time::Add(&now, &m_timeout, &when);

	if (Time::IsGreater(&now, &when))
	{
		memcpy(&m_last, &now, sizeof(now));
		return true;
	}
	return false;

}


Fix compiler warning which is not support until c++11
Fix compiler warning which is not support until c++11
