线程类,封装了 std::thread 和 Event 类。
More...
#include <thread.h>
|
| template<class F, class... Args> |
| std::thread | make_thread (std::true_type, F &&f, Args &&...args) |
| | true_type分支,用于处理带有const Event &参数的可调用对象。
|
| template<class F, class... Args> |
| std::thread | make_thread (std::false_type, F &&f, Args &&...args) |
| | false_type分支,用于处理不带const Event &参数的可调用对象。
|
线程类,封装了 std::thread 和 Event 类。
提供了线程的启动、停止和等待操作,以及事件标志的设置和检查。
◆ Thread() [1/4]
| console::Thread::Thread |
( |
| ) |
|
|
default |
默认构造函数,创建线程对象但不启动线程。
- Note
- 稍后可以通过赋值启动任务。
◆ Thread() [2/4]
template<class F, class... Args>
| console::Thread::Thread |
( |
F && | f, |
|
|
Args &&... | args ) |
|
inline |
构造函数,创建线程对象并启动线程。
- Template Parameters
-
| F | 可调用对象类型。 |
| Args | 可调用对象的参数类型。 |
- Parameters
-
- Note
- 通过标签分发,如果首个参数为const Event &, 分发至true_type分支,否则分发至false_type分支。
◆ ~Thread()
| console::Thread::~Thread |
( |
| ) |
|
|
inline |
◆ Thread() [3/4]
| console::Thread::Thread |
( |
const Thread & | | ) |
|
|
delete |
◆ Thread() [4/4]
| console::Thread::Thread |
( |
Thread && | t | ) |
|
|
inline |
◆ detach()
| void console::Thread::detach |
( |
| ) |
|
|
inline |
◆ get_id()
| std::thread::id console::Thread::get_id |
( |
| ) |
const |
|
inline |
◆ join()
| void console::Thread::join |
( |
| ) |
|
|
inline |
◆ joinable()
| bool console::Thread::joinable |
( |
| ) |
const |
|
inline |
◆ make_thread() [1/2]
template<class F, class... Args>
| std::thread console::Thread::make_thread |
( |
std::false_type | , |
|
|
F && | f, |
|
|
Args &&... | args ) |
|
inlineprivate |
false_type分支,用于处理不带const Event &参数的可调用对象。
- Template Parameters
-
| F | 可调用对象类型。 |
| Args | 可调用对象的参数类型。 |
- Parameters
-
- Returns
- 新创建的线程对象。
◆ make_thread() [2/2]
template<class F, class... Args>
| std::thread console::Thread::make_thread |
( |
std::true_type | , |
|
|
F && | f, |
|
|
Args &&... | args ) |
|
inlineprivate |
true_type分支,用于处理带有const Event &参数的可调用对象。
- Template Parameters
-
| F | 可调用对象类型。 |
| Args | 可调用对象的参数类型。 |
- Parameters
-
- Returns
- 新创建的线程对象。
◆ native_handle()
| auto console::Thread::native_handle |
( |
| ) |
-> decltype(thread_.native_handle()) |
|
inline |
◆ operator=() [1/2]
◆ operator=() [2/2]
移动赋值。
- Parameters
-
- Returns
- 移动后的线程对象。
◆ stop()
| void console::Thread::stop |
( |
| ) |
|
|
inline |
◆ swap()
| void console::Thread::swap |
( |
Thread & | t | ) |
|
|
inlinenoexcept |
◆ swap
交换两个线程对象。
- Parameters
-
| lhs | 要交换的线程对象。 |
| rhs | 要交换的线程对象。 |
◆ event_
| std::unique_ptr<Event> console::Thread::event_ |
|
private |
◆ thread_
| std::thread console::Thread::thread_ |
|
private |
The documentation for this class was generated from the following file: