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#if defined(NEFORCE_STANDARD_20) || defined(NEXUSFORCE_ENABLE_DOXYGEN)
14# include <coroutine>
15NEFORCE_BEGIN_NAMESPACE__
16
22
31template <typename Res, typename... Args>
32struct coroutine_traits;
33
34NEFORCE_BEGIN_INNER__
35
36template <typename, typename = void>
37struct coroutine_traits_impl {};
38
39template <typename Res>
40struct coroutine_traits_impl<Res, void_t<typename Res::promise_type>> {
41 using promise_type = typename Res::promise_type;
42};
43
44NEFORCE_END_INNER__
45
51template <typename Res, typename... Args>
52struct coroutine_traits : inner::coroutine_traits_impl<Res> {};
53
54
63template <typename Promise = void>
64using coroutine_handle = std::coroutine_handle<Promise>;
65 // Coroutine
67
72
77template <typename Promise>
78struct hash<coroutine_handle<Promise>> {
79 size_t operator()(const coroutine_handle<Promise>& handle) const noexcept {
80 return reinterpret_cast<size_t>(handle.address());
81 }
82};
83 // HashPrimary
85
91
95using noop_coroutine_promise = std::noop_coroutine_handle;
96
101
110
111
120 constexpr bool await_ready() const noexcept { return false; }
121 constexpr void await_suspend(coroutine_handle<>) const noexcept {}
122 constexpr void await_resume() const noexcept {}
123};
124
133 constexpr bool await_ready() const noexcept { return true; }
134 constexpr void await_suspend(coroutine_handle<>) const noexcept {}
135 constexpr void await_resume() const noexcept {}
136};
137 // Coroutine
139
140NEFORCE_END_NAMESPACE__
141#endif
142#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
空操作协程句柄类型别名
NEFORCE_ALWAYS_INLINE_INLINE thread::native_handle_type handle() noexcept
获取当前线程句柄
void void_t
将任意类型映射为void
哈希函数库
协程特征主模板
哈希函数的主模板
始终暂停的等待器
从不暂停的等待器