mqttclient
mqttclient copied to clipboard
建议弃用usleep
建议修改Linux平台的platform_timer_usleep实现,usleep是非可重入的,也是非线程安全的,而且延迟时间不精确,延时超过1秒时,也是不符合函数的使用规定的。建议使用信号量实现,或者使用select。
/*sleep in us*/
void usSleep(unsigned int nusecs)
{
struct timeval tval;
tval.tv_sec = nusecs / 1000000;
tval.tv_usec = nusecs % 1000000;
select(0, NULL, NULL, NULL, &tval);
}
很好的建议~
感谢