C++ Boost ASIO 简单的周期性定时器? [英] C++ Boost ASIO simple periodic timer?

查看:25
本文介绍了C++ Boost ASIO 简单的周期性定时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个非常简单的周期性计时器,每 50 毫秒调用一次我的代码.我可以制作一个一直休眠 50 毫秒的线程(但这很痛苦)...我可以开始研究 Linux API 来制作计时器(但它不可移植)...

I want a very simple periodic timer to call my code every 50ms. I could make a thread that sleeps for 50ms all the time (but that's a pain)... I could start looking into Linux API's for making timers (but it's not portable)...

喜欢使用 boost.. 我只是不确定这是否可能.boost 是否提供此功能?

I'd like to use boost.. I'm just not sure it's possible. Does boost provide this functionality?

推荐答案

Boosts Asio 教程中的第二个示例对此进行了解释.
您可以在此处找到它.

The second example on Boosts Asio tutorials explains it.
You can find it here.

之后,检查第三个例子 看看你如何以周期性的时间间隔再次调用它

After that, check the 3rd example to see how you can call it again with a periodic time intervall

这篇关于C++ Boost ASIO 简单的周期性定时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆