函數(shù):time(time_t * timer)
1.當(dāng)參數(shù)為NULL時(大多數(shù)情況下)豪治,返回值是從1970年1月1日至今所經(jīng)歷的時間(以秒為單位)座掘,把下面的代碼放在一個線程或者while循環(huán)下啦吧,定時執(zhí)行某函數(shù)邑退,見下面的代碼:
int DELAY_TIME;
bool bFirst_time;
int cost_time ;
time_t startTm, endTm;
bFirst_time = true;
if(DELAY_TIME > 0)
{
if (bFirst_time)
{
time(&startTm);
//printf("Use Time:%d\n", startTm);
bFirst_time = false;
}
time(&endTm);
cost_time = endTm - startTm;
//printf("cost_time:%d\n", cost_time);
if (cost_time > DELAY_TIME)
{
for(size_t i = 0 ; i < yaoxin_list.size() ;i++)
{
DWORD index = yaoxin_list[i].index ;
if(index < dwPacketLength-8)
{
yaoxin_list[i].state = pbyPacket[8+index-1] ;
}
}
SendAllYx() ;
startTm = endTm;
}
}