#include "StdAfx.h"
#include "intervaltimer.h"

CIntervalTimer::CIntervalTimer(int interval)
{
	m_interval = interval;
	m_oldTick = GetTickCount();
}

CIntervalTimer::~CIntervalTimer(void)
{
}

//	タイムアウトした？
int CIntervalTimer::IsTimeout()
{
	DWORD tick = GetTickCount();

	if(m_oldTick + m_interval < tick || tick < m_oldTick)
	{
		m_oldTick = GetTickCount();
		return(1);
	}
	return(0);
}

CIntervalTimer::operator int()
{
	return(IsTimeout());
}

void CIntervalTimer::Reset()
{
	m_oldTick = GetTickCount();
}
