std::this_thread::sleep_for

来自cppreference.com
< cpp‎ | thread

 
 
线程的支持库
主题
原文:
Threads
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
thread(C++11)
this_thread命名空间
原文:
this_thread namespace
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
get_id(C++11)
yield(C++11)
sleep_for(C++11)
sleep_until(C++11)
相互排斥
原文:
Mutual exclusion
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
mutex(C++11)
timed_mutex(C++11)
recursive_mutex(C++11)
recursive_timed_mutex(C++11)
通用锁管理
原文:
Generic lock management
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
lock_guard(C++11)
unique_lock(C++11)
defer_lock_t
try_to_lock_t
adopt_lock_t
(C++11)
(C++11)
(C++11)
lock(C++11)
try_lock(C++11)
defer_lock
try_to_lock
adopt_lock
(C++11)
(C++11)
(C++11)
条件变量
原文:
Condition variables
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
condition_variable(C++11)
condition_variable_any(C++11)
notify_all_at_thread_exit(C++11)
cv_status(C++11)
期货
原文:
Futures
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
promise(C++11)
future(C++11)
shared_future(C++11)
packaged_task(C++11)
async(C++11)
launch(C++11)
future_status(C++11)
future_error(C++11)
future_category(C++11)
future_errc(C++11)
 
在头文件 <thread> 中定义
template< class Rep, class Period >
void sleep_for( std::chrono::duration<Rep,Period> sleep_duration );
(C++11 起)
。阻止执行当前线程的“至少”指定的sleep_duration.
原文:
Blocks the execution of the current thread for at least the specified sleep_duration.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
。呼叫sleep_for可能会阻止长于sleep_duration,如果底层操作系统不支持指定的sleep_duration的粒度.
原文:
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.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

目录

[编辑] 。参数。

sleep_duration -
。持续时间睡觉。
原文:
time duration to sleep
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

===。 返回值。===

。 (无)。
原文:
(none)
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑] 。例外。

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

[编辑] 。另请参阅。

(C++11)
暂停当前线程的执行直到特定的时间点
(函数) [edit]