赞
踩
1、采用select
- timeval timeOut;
- timeOut.tv_sec = useconds/1000000;
- timeOut.tv_usec = useconds%1000000;
- TLOG_INFO("tv_sec=%lld, tv_usec=%lld.", timeOut.tv_sec, timeOut.tv_usec);
- if (0 != select(0, NULL, NULL, NULL, &timeOut)){
- TLOG_INFO("select error");
- return false;
- }
2、nanosleep
- struct timespec req;
- req.tv_sec = useconds/1000000;
- req.tv_nsec = (useconds%1000000) * 1000;
- int ret = nanosleep(&req, NULL);
- if (-1 == ret){
- TLOG_ERROR ("nanousleep %8u not support.", useconds);
- }
3、usleep
usleep(useconds)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。