1#ifndef NEFORCE_CORE_ASYNC_SCOPED_THREAD_HPP__
2#define NEFORCE_CORE_ASYNC_SCOPED_THREAD_HPP__
12NEFORCE_BEGIN_NAMESPACE__
40 template <
typename Callable,
typename Object,
typename... Args>
41 static constexpr bool pmf_expects_stop_token =
48 template <
typename Callable,
typename Object,
typename... Args,
49 enable_if_t<pmf_expects_stop_token<Callable, Object, Args...>,
int> = 0>
50 static thread create(
stop_source& source, Callable func, Object&&
object, Args&&... args) {
54 template <
typename Callable,
typename... Args,
62 template <
typename Callable,
typename... Args,
66 static thread create(stop_source& , Callable func, Args&&... args) {
68 "jthread arguments must be invocable after conversion to rvalues");
89 template <typename Callable, typename... Args,
130 _NEFORCE
swap(stop_source_, other.stop_source_);
131 _NEFORCE
swap(thread_, other.thread_);
138 NEFORCE_NODISCARD
bool joinable() const noexcept {
return thread_.joinable(); }
145 void join() { thread_.join(); }
159 NEFORCE_NODISCARD
id get_id() const noexcept {
return thread_.get_id(); }
192NEFORCE_END_NAMESPACE__
bool joinable() const noexcept
检查线程是否可被等待
void swap(scoped_thread &other) noexcept
交换两个scoped_thread对象
scoped_thread & operator=(const scoped_thread &)=delete
禁止拷贝赋值
scoped_thread & operator=(scoped_thread &&other) noexcept
移动赋值运算符
stop_token get_stop_token() const noexcept
获取停止令牌
id get_id() const noexcept
获取线程ID
bool request_stop() noexcept
请求线程停止
scoped_thread() noexcept=default
默认构造函数
scoped_thread(scoped_thread &&other) noexcept=default
移动构造函数
scoped_thread(const scoped_thread &)=delete
禁止拷贝构造
native_handle_type native_handle() const
获取原生线程句柄
stop_source get_stop_source() noexcept
获取停止源
thread::native_handle_type native_handle_type
原生句柄类型
stop_token get_token() const noexcept
获取停止令牌
::HANDLE native_handle_type
系统线程句柄类型
constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
constexpr bool is_invocable_v
is_invocable的便捷变量模板
typename remove_cvref< T >::type remove_cvref_t
remove_cvref的便捷别名
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
void swap()=delete
删除无参数的swap重载
typename decay< T >::type decay_t
decay的便捷别名
constexpr bool conjunction_v
conjunction的便捷变量模板
constexpr bool is_same_v
is_same的便捷变量模板
typename enable_if< Test, T >::type enable_if_t
enable_if的便捷别名