我们知道boost::this_thread::sleep_for(...)
可用于将当前正在运行的线程置于睡眠状态。与常规的sleep()
函数有何不同。看来我们使用boost::this_thread::sleep_for(...)
的每个地方都可以简单地用sleep()
方法代替,而不影响结果。任何人都可以投入一些光。使用boost :: this_thread :: sleep_for()和普通的sleep()函数有什么区别?
0
A
回答
2
在C++ 11出现之前,C++没有提供睡眠函数,它提供了std::thread::sleep_for()。所以Boost提供了自己的代码,使你的代码独立于平台。
0
睡眠仅在1秒的粒度级别上运行,boost :: this_thread :: sleep_for允许睡眠时间小于1秒的粒度。
相关问题
- 1. 的std :: this_thread :: sleep_for()和纳秒
- 2. MacVim和普通Vim有什么区别?
- 3. 替代std :: this_thread :: sleep_for()
- 4. 使用线程池和普通线程有什么区别?
- 5. java的sleep()和c的sleep()之间的区别是什么?
- 6. boost :: thread sleep()是做什么的?
- 7. EOF和普通整数有什么区别?下面
- 8. boost :: io_service poll_one和run_one有什么区别?
- 9. boost :: static_pointer_cast vs boost :: shared_static_cast有什么区别?
- 10. 分别使用sleep()和GetAsyncKeyState函数
- 11. 可可触摸类和普通的swift类有什么区别?
- 12. Crypt ...和CP ...函数有什么区别?
- 13. NtFsControlFile()和DeviceIoControl()函数有什么区别?
- 14. $ get和$ find函数有什么区别?
- 15. 函数getAddUrl和getAddToCartUrl有什么区别?
- 16. 源文件夹和(普通)文件夹有什么区别
- 17. 静态结构和普通结构有什么区别?
- 18. round()和trunc()函数有什么区别?
- 19. setInformativeText和setText函数有什么区别?
- 20. 代理服务器和普通服务器有什么区别?
- 21. Quartz Scheduler和普通Java线程有什么区别
- 22. 制片人和普通演员之间有什么区别?
- 23. 为什么使用std :: thread :: hardware_concurrency()和boost :: thread :: hardware_concurrency()会有区别?
- 24. 函数调用和函数引用有什么区别?
- 25. this_thread :: sleep_for影响其他线程
- 26. min和普通文件有什么区别,我应该使用哪一个?
- 27. 普通函数和异步函数返回的Promise类型是否有区别?
- 28. boost :: bind和boost :: lambda :: bind有什么区别?
- 29. boost :: signals2 :: mutex和boost :: thread :: mutex有什么区别?
- 30. Boost :: bind和Boost Phoenix :: bind有什么区别?
'sleep()'不可移植。 – chris