简体   繁体   中英

C++ timeout function

I want to realize a timeout function in C++ on a Atmel evaluation kit.

The program should open the function "start()" and if this function is not completed within "0.5s" it should be killed.

Are there any existing function to do jobs like this?

regard matl

Yes: std::future::wait_for . You get either future_status::ready or future_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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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