Espaços nominais
Variantes
Acções

std::this_thread::sleep_for

Da cppreference.com
< cpp‎ | thread

 
 
Biblioteca de suporte a discussão
Threads
Original:
Threads
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
this_thread namespace
Original:
this_thread namespace
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
sleep_for
(C++11)
Exclusão mútua
Original:
Mutual exclusion
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Gestão de bloqueio genérico
Original:
Generic lock management
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Variáveis ​​de condição
Original:
Condition variables
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Futuros
Original:
Futures
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
(C++11)
 
Definido no cabeçalho <thread>
template< class Rep, class Period >
void sleep_for( std::chrono::duration<Rep,Period> sleep_duration );
(desde C++11)
Bloqueia a execução da thread atual para pelo menos o sleep_duration especificado.
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.
Chamadas para sleep_for pode bloquear por mais de sleep_duration se o sistema operacional subjacente não suporta a granularidade especificada pelo 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.

Índice

[editar] Parâmetros

sleep_duration -
tempo de duração para dormir
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.

[editar] Valor de retorno

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

[editar] Exceções

noexcept specification:  
noexcept
  (desde C++11)

[editar] Exemplo

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

Saída:

Hello waiter
Waited 2000 ms

[editar] Veja também

stops the execution of the current thread until a specified time point
(função) [edit]