简体   繁体   English

C ++超时功能

[英]C++ timeout function

I want to realize a timeout function in C++ on a Atmel evaluation kit. 我想在Atmel评估套件上用C ++实现超时功能。

The program should open the function "start()" and if this function is not completed within "0.5s" it should be killed. 程序应打开函数“ start()”,如果该函数未在“ 0.5s”内完成,则应将其杀死。

Are there any existing function to do jobs like this? 有现成的功能可以执行这样的工作吗?

regard matl 关于物质

Yes: std::future::wait_for . 是: std::future::wait_for You get either future_status::ready or future_status::timeout . 您会得到future_status::readyfuture_status::timeout

In my experience, these kinds of functions are always hand-crafted because in embedded systems, the target system is not standardized. 以我的经验,这些功能总是手工制作的,因为在嵌入式系统中,目标系统未标准化。

You could purchase an OS and use methods like messaging timeouts and sleeping. 您可以购买操作系统,并使用诸如消息超时和睡眠之类的方法。

Without an OS, you have to craft the functionality yourself using a timer and the timer interrupt (ISR). 如果没有操作系统,则必须使用计时器和计时器中断(ISR)自行设计功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM