matl
matl

Reputation: 135

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

Upvotes: 1

Views: 4964

Answers (2)

Thomas Matthews
Thomas Matthews

Reputation: 57678

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).

Upvotes: 1

MSalters
MSalters

Reputation: 179779

Yes: std::future::wait_for. You get either future_status::ready or future_status::timeout.

Upvotes: 1

Related Questions