From the course: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Sleeping - C++ Tutorial
From the course: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices
Sleeping
- The thread header provides two functions for sleeping a thread. Sleep_for specifies a duration of time for the thread to sleep and sleep_until specifies an end time for sleeping a thread. This is sleep.cbp from chapter six of the exercise files. You notice we have a few using statements here in the standard chrono name space. We have steady_clock and duration. Steady_clock provides a chrono time point object and duration provides a chrono duration object. In the this_thread name space we have sleep_for and sleep_until. These are in the this_thread name space and they operate on the current thread. The sleep_for function takes a chrono duration object and the sleep_until function takes a chrono time point object. And then we have this name space for chrono literals that we're using for seconds and milliseconds. And we'll see that down here in a moment. Down here in main we take a steady_clock now, which is a time…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.