开发者

How can i create watchdog timer using c++ and boost

What is the best and shortest way to create a WatchDogTimer class, which can wait some time and then died?

So when I'开发者_StackOverflow社区m doing something like

WatchDogTimer wdt (10);

wdt will be available only in next 10 seconds.

How can I do this?

ps: yeah, I saw that thread, but it did not actually help.


Create an object on the heap with new and hand it to a shared_ptr. Then hold that shared pointer only from a thread that sleeps for 10 seconds before exiting. Make sure the thread is the only instance of shared_ptr and all other references are weak_ptrs. After the 10 seconds weak_ptr::get() will return null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜