名前空間
変種
操作

std::this_thread::sleep_for

提供: cppreference.com
< cpp‎ | thread

Defined in header <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.
基礎となるオペレーティング·システムが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.

目次

[編集] パラメータ

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.

[編集] 例外

noexcept specification:  
noexcept
  (C++11およびそれ以降)

[編集]

#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

[編集] も参照してください

stops the execution of the current thread until a specified time point
(関数) [edit]