function
<thread>
std::this_thread::sleep_fortemplate <class Rep, class Period> void sleep_for (const chrono::duration<Rep,Period>& rel_time);
Sleep for time span
Blocks execution of the calling thread during the span of time specified by rel_time.The execution of the current thread is stopped until at least rel_time has passed from now. Other threads continue their execution.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// this_thread::sleep_for example
#include <iostream> // std::cout, std::endl
#include <thread> // std::this_thread::sleep_for
#include <chrono> // std::chrono::seconds
int main()
{
std::cout << "countdown:\n";
for (int i=10; i>0; --i) {
std::cout << i << std::endl;
std::this_thread::sleep_for (std::chrono::seconds(1));
}
std::cout << "Lift off!\n";
return 0;
}
countdown: 10 9 8 7 6 5 4 3 2 1 Lift off!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4