◐ Shell
clean mode source ↗

std::this_thread::sleep_for – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

definiert in Header

<thread>

template< class Rep, class Period > void sleep_for( std::chrono::duration<Rep,Period> sleep_duration );

(seit C++11)

Blockiert die Ausführung des aktuellen Threads für mindestens die angegebene 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.

Anrufe auf sleep_for kann länger als sleep_duration sperren, wenn das zugrunde liegende Betriebssystem nicht unterstützt die Granularität von sleep_duration angegeben .

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.

Parameter

sleep_duration -

Zeitdauer zu schlafen

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.

Rückgabewert

(None)

Original:

(none)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Ausnahmen

Beispiel

#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";
}

Output:

Hello waiter
Waited 2000 ms

Siehe auch

stoppt die Ausführung des aktuellen Threads bis zu einem festgelegten Zeitpunkt
(Funktion) [edit]