windows usleep 解决办法

1、linux 系统环境下 有库函数 usleep
2、windows 系统环境下 没有usleep
3、windows 系统环境下模拟 linux 实现 usleep

//调用usleep
usleep((unsigned long)((tox_do_interval_ms - (ms_end - ms_start)) * 1000));

//实现usleep
static  usleep(unsigned long usec)
{
	HANDLE timer;
	LARGE_INTEGER interval;
	interval.QuadPart = (10 * usec);

	timer = CreateWaitableTimer(NULL, TRUE, NULL);
	SetWaitableTimer(timer, &interval, 0, NULL, NULL, 0);
	WaitForSingleObject(timer, INFINITE);
	CloseHandle(timer);
}

你可能感兴趣的:(linux,usleep)