std::this_thread::sleep_for
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <thread>
|
||
| template< class Rep, class Period > void sleep_for( std::chrono::duration<Rep,Period> sleep_duration ); |
(начиная с C++11) | |
Блокирует выполнение текущего потока для' по крайней мере, указанный
sleep_duration. Original:
Blocks the execution of the current thread for at least the specified
sleep_duration. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Звонки на
sleep_for может блокировать дольше, чем sleep_duration, если операционная система не поддерживает детализацию указанные sleep_duration.Original:
Calls to
sleep_for may block for longer than sleep_duration if the underlying operating system does not support the granularity specified by sleep_duration.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Содержание |
[править] Параметры
| sleep_duration | - | продолжительность времени для сна
Original: time duration to sleep The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[править] Возвращаемое значение
(Нет)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] Исключения
[править] Пример
#include <iostream> #include <chrono> #include <thread> int main() { std::cout << "Hello waiter" << std::endl; std::chrono::milliseconds dura( 2000 ); std::this_thread::sleep_for( dura ); std::cout << "Waited 2000 ms\n"; }
Вывод:
Hello waiter Waited 2000 ms
[править] См. также
| (C++11) |
stops the execution of the current thread until a specified time point (функция) |