NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
coroutine.hpp
浏览该文件的文档.
1#ifndef NEFORCE_CORE_ASYNC_COROUTINE_HPP__
2#define NEFORCE_CORE_ASYNC_COROUTINE_HPP__
3
11
13#ifdef NEFORCE_STANDARD_20
15# include <coroutine>
16NEFORCE_BEGIN_NAMESPACE__
17
23
32template <typename Res, typename... Args>
33struct coroutine_traits;
34
35NEFORCE_BEGIN_INNER__
36
37template <typename, typename = void>
38struct coroutine_traits_impl {};
39
40template <typename Res>
41struct coroutine_traits_impl<Res, void_t<typename Res::promise_type>> {
42 using promise_type = typename Res::promise_type;
43};
44
45NEFORCE_END_INNER__
46
52template <typename Res, typename... Args>
53struct coroutine_traits : inner::coroutine_traits_impl<Res> {};
54
55
64template <typename Promise = void>
65using coroutine_handle = std::coroutine_handle<Promise>;
66 // Coroutine
68
73
78template <typename Promise>
79struct hash<coroutine_handle<Promise>> {
80 size_t operator()(const coroutine_handle<Promise>& handle) const noexcept {
81 return reinterpret_cast<size_t>(handle.address());
82 }
83};
84 // HashPrimary
86
92
96using noop_coroutine_promise = std::noop_coroutine_handle;
97
102
110inline noop_coroutine_handle noop_coroutine() noexcept { return {}; }
111
112
121 NEFORCE_NODISCARD constexpr bool await_ready() const noexcept { return false; }
122 constexpr void await_suspend(coroutine_handle<> /*unused*/) const noexcept {}
123 constexpr void await_resume() const noexcept {}
124};
125
134 NEFORCE_NODISCARD constexpr bool await_ready() const noexcept { return true; }
135 constexpr void await_suspend(coroutine_handle<> /*unused*/) const noexcept {}
136 constexpr void await_resume() const noexcept {}
137};
138 // Coroutine
140
141NEFORCE_END_NAMESPACE__
142#endif
143#endif // NEFORCE_CORE_ASYNC_COROUTINE_HPP__
核心配置头文件
noop_coroutine_handle noop_coroutine() noexcept
获取空操作协程句柄
std::coroutine_handle< Promise > coroutine_handle
协程句柄
std::noop_coroutine_handle noop_coroutine_promise
空操作协程的promise类型别名
coroutine_handle< noop_coroutine_promise > noop_coroutine_handle
空操作协程句柄类型别名
thread::native_handle_type handle() noexcept
获取当前线程句柄
void void_t
将任意类型映射为void
哈希函数库
协程特征主模板
哈希函数的主模板
始终暂停的等待器
从不暂停的等待器