Is there time?

One of the items I will need is a wait function. I am used to having one in Arduino based C and Python 3.x, but this is new in C++ from what I can see from my searches of the web. So I thought I would cover it here for a short post.

There is a boost function for thread handling that can be used to do a wait. Apparently,​ the compile C++11 can also handle this in the build classes. As we are using AWS’s Cloud9 development enviroment, lets use the C++11 solution.

To code this you will need an Include of chrono and thread; this code will give you a 1/2 second sleep:

std::this_thread::sleep_for(std::chrono::milliseconds(500));

Again, we have to type std:: everywhere as that is the coding standard of the day. The definition of time is also enjoying extra typing with a whopper of stt::chrono::milliseconds. That is almost reaching silly. Almost.

I have not learned the thread safe coding stuff supplied now by C++11. More to learn one of these days.

Well I thought I would take the time to cover wait.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s