# included. | # included. | ||||
# The default value is: NO. | # The default value is: NO. | ||||
EXTRACT_LOCAL_METHODS = NO | |||||
EXTRACT_LOCAL_METHODS = YES | |||||
# If this flag is set to YES, the members of anonymous namespaces will be | # If this flag is set to YES, the members of anonymous namespaces will be | ||||
# extracted and appear in the documentation as a namespace called | # extracted and appear in the documentation as a namespace called | ||||
# are hidden. | # are hidden. | ||||
# The default value is: NO. | # The default value is: NO. | ||||
EXTRACT_ANON_NSPACES = NO | |||||
EXTRACT_ANON_NSPACES = YES | |||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all | # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all | ||||
# undocumented members inside documented classes or files. If set to NO these | # undocumented members inside documented classes or files. If set to NO these | ||||
# has no effect if EXTRACT_ALL is enabled. | # has no effect if EXTRACT_ALL is enabled. | ||||
# The default value is: NO. | # The default value is: NO. | ||||
HIDE_UNDOC_CLASSES = NO | |||||
HIDE_UNDOC_CLASSES = YES | |||||
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend | # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend | ||||
# declarations. If set to NO, these declarations will be included in the | # declarations. If set to NO, these declarations will be included in the |
#ifndef DOXYGEN_SKIP_PROPERTY | #ifndef DOXYGEN_SKIP_PROPERTY | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
template<class _Ty> | template<class _Ty> | ||||
struct awaitable_impl_t | struct awaitable_impl_t |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { | ||||
using semaphore_t = channel_t<bool>; | using semaphore_t = channel_t<bool>; | ||||
} //namespace v1 | } //namespace v1 | ||||
} //RESUMEF_NS | |||||
} //namespace resumef |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
namespace detail | namespace detail | ||||
{ | { | ||||
template<class _Ty, class _Opty> | template<class _Ty, class _Opty> | ||||
size_t capacity() const noexcept; | size_t capacity() const noexcept; | ||||
/** | /** | ||||
* @brief 在协程中从channel_t里读取一个数据。参考read()函数 | |||||
* @brief 在协程中从channel_t里读取一个数据。 | |||||
* @see 参考{read}()函数 | |||||
*/ | */ | ||||
read_awaiter operator co_await() const noexcept; | read_awaiter operator co_await() const noexcept; | ||||
read_awaiter read() const noexcept; | read_awaiter read() const noexcept; | ||||
/** | /** | ||||
* @brief 在协程中向channel_t里写入一个数据。参考write()函数 | |||||
* @brief 在协程中向channel_t里写入一个数据。 | |||||
* @see 参考{write}()函数 | |||||
*/ | */ | ||||
template<class U | template<class U | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | #ifndef DOXYGEN_SKIP_PROPERTY | ||||
using semaphore_t = channel_t<bool, false, true>; | using semaphore_t = channel_t<bool, false, true>; | ||||
} //namespace channel_v2 | } //namespace channel_v2 | ||||
} //RESUMEF_NS | |||||
} //namespace resumef |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { | ||||
} | } | ||||
} //namespace channel_v2 | } //namespace channel_v2 | ||||
} //RESUMEF_NS | |||||
} //namespace resumef |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
template <typename T> | template <typename T> | ||||
struct counted_ptr | struct counted_ptr |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
struct get_current_scheduler_awaitor | struct get_current_scheduler_awaitor | ||||
{ | { |
#define LIB_RESUMEF_VERSION 20905 // 2.9.5 | #define LIB_RESUMEF_VERSION 20905 // 2.9.5 | ||||
#if defined(RESUMEF_MODULE_EXPORT) | |||||
#define RESUMEF_NS export namespace resumef | |||||
#else | |||||
#define RESUMEF_NS namespace resumef | |||||
#endif | |||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
struct scheduler_t; | struct scheduler_t; | ||||
template<class _Ty = void> | template<class _Ty = void> | ||||
struct state_base_t; | struct state_base_t; | ||||
struct switch_scheduler_t; | struct switch_scheduler_t; | ||||
#else //DOXYGEN_SKIP_PROPERTY | |||||
namespace resumef { | |||||
#endif //DOXYGEN_SKIP_PROPERTY | #endif //DOXYGEN_SKIP_PROPERTY | ||||
template<typename _PromiseT = void> | template<typename _PromiseT = void> | ||||
extern std::atomic<intptr_t> g_resumef_state_id; | extern std::atomic<intptr_t> g_resumef_state_id; | ||||
#endif | #endif | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
template<class T> | template<class T> | ||||
struct remove_cvref | struct remove_cvref |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
namespace detail | namespace detail | ||||
{ | { | ||||
struct event_v2_impl; | struct event_v2_impl; |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
enum struct error_code | enum struct error_code | ||||
{ | { |
| | ||||
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
template<class _Ty> | template<class _Ty> | ||||
struct [[nodiscard]] future_t | struct [[nodiscard]] future_t |
#pragma push_macro("new") | #pragma push_macro("new") | ||||
#undef new | #undef new | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
template <typename _Ty, typename promise_type> | template <typename _Ty, typename promise_type> | ||||
struct generator_iterator; | struct generator_iterator; | ||||
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
template<class _Node, class _Nodeptr = _Node*, class _Sty = uint32_t> | template<class _Node, class _Nodeptr = _Node*, class _Sty = uint32_t> | ||||
struct intrusive_link_queue | struct intrusive_link_queue |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
namespace detail | namespace detail | ||||
{ | { | ||||
struct mutex_v2_impl; | struct mutex_v2_impl; | ||||
awaiter/*batch_unlock_t*/ lock() const noexcept; | awaiter/*batch_unlock_t*/ lock() const noexcept; | ||||
/** | /** | ||||
* @brief 等同调用 co_await lock()。 | |||||
* @brief 在协程中加锁。 | |||||
* @see 等同调用 co_await {lock}()。 | |||||
* @return [co_await] batch_unlock_t | * @return [co_await] batch_unlock_t | ||||
*/ | */ | ||||
awaiter/*batch_unlock_t*/ operator co_await() const noexcept; | awaiter/*batch_unlock_t*/ operator co_await() const noexcept; |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#undef new | #undef new | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | #ifndef DOXYGEN_SKIP_PROPERTY | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
struct suspend_on_initial; | struct suspend_on_initial; | ||||
struct suspend_on_final; | struct suspend_on_final; |
| | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
/* | /* | ||||
Note: the awaiter object is part of coroutine state (as a temporary whose lifetime crosses a suspension point) | Note: the awaiter object is part of coroutine state (as a temporary whose lifetime crosses a suspension point) |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
task_base_t::~task_base_t() | task_base_t::~task_base_t() | ||||
{ | { |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
/** | /** | ||||
* @brief 协程任务的基类。 | * @brief 协程任务的基类。 | ||||
*/ | */ |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
//使用自旋锁完成的线程安全的环形队列。 | //使用自旋锁完成的线程安全的环形队列。 | ||||
//支持多个线程同时push和pop。 | //支持多个线程同时push和pop。 |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
//目前无法解决三个索引数值回绕导致的问题 | //目前无法解决三个索引数值回绕导致的问题 | ||||
//如果为了避免索引回绕的问题,索引采用uint64_t类型, | //如果为了避免索引回绕的问题,索引采用uint64_t类型, |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
//使用自旋锁完成的线程安全的环形队列。 | //使用自旋锁完成的线程安全的环形队列。 | ||||
//支持多个线程同时push和pop。 | //支持多个线程同时push和pop。 |
std::atomic<intptr_t> g_resumef_state_id = 0; | std::atomic<intptr_t> g_resumef_state_id = 0; | ||||
#endif | #endif | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
const char * future_error_string[(size_t)error_code::max__] | const char * future_error_string[(size_t)error_code::max__] | ||||
{ | { |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
struct local_scheduler; | |||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
struct scheduler_t : public std::enable_shared_from_this<scheduler_t> | struct scheduler_t : public std::enable_shared_from_this<scheduler_t> | ||||
{ | { | ||||
private: | private: |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
future_t<> sleep_until_(std::chrono::system_clock::time_point tp_, scheduler_t& scheduler_) | future_t<> sleep_until_(std::chrono::system_clock::time_point tp_, scheduler_t& scheduler_) | ||||
{ | { |
// | // | ||||
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
struct scheduler_t; | |||||
future_t<> sleep_until_(std::chrono::system_clock::time_point tp_, scheduler_t& scheduler_); | future_t<> sleep_until_(std::chrono::system_clock::time_point tp_, scheduler_t& scheduler_); | ||||
inline future_t<> sleep_for_(std::chrono::system_clock::duration dt_, scheduler_t& scheduler_) | inline future_t<> sleep_for_(std::chrono::system_clock::duration dt_, scheduler_t& scheduler_) |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#if defined(RESUMEF_USE_CUSTOM_SPINLOCK) | #if defined(RESUMEF_USE_CUSTOM_SPINLOCK) | ||||
using spinlock = RESUMEF_USE_CUSTOM_SPINLOCK; | using spinlock = RESUMEF_USE_CUSTOM_SPINLOCK; |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
state_base_t::~state_base_t() | state_base_t::~state_base_t() | ||||
{ | { |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
struct state_base_t | struct state_base_t | ||||
{ | { | ||||
using _Alloc_char = std::allocator<char>; | using _Alloc_char = std::allocator<char>; |
| | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
template<class _PromiseT, typename _Enable> | template<class _PromiseT, typename _Enable> | ||||
void state_future_t::promise_initial_suspend(coroutine_handle<_PromiseT> handler) | void state_future_t::promise_initial_suspend(coroutine_handle<_PromiseT> handler) |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
struct switch_scheduler_awaitor | struct switch_scheduler_awaitor | ||||
{ | { | ||||
//{ | //{ | ||||
// return { &sch }; | // return { &sch }; | ||||
//} | //} | ||||
/** | |||||
* @fn 将本协程切换到指定调度器上运行。 | |||||
* @details 由于调度器必然在某个线程里运行,故达到了切换到特定线程里运行的目的。\n | |||||
* 如果指定的协程就是本协程的调度器,则协程不暂停直接运行接下来的代码。 | |||||
* 如果指定的协程不是本协程的调度器,则协程暂停后放入到目的协程的调度队列,等待下一次运行。 | |||||
* @param sch 将要运行此后代码的协程 | |||||
*/ | |||||
inline switch_scheduler_awaitor via(scheduler_t& sch) noexcept | inline switch_scheduler_awaitor via(scheduler_t& sch) noexcept | ||||
{ | { | ||||
return { &sch }; | return { &sch }; | ||||
} | } | ||||
/** | |||||
* @fn 将本协程切换到指定调度器上运行。 | |||||
* @see 参考{via}(scheduler_t&)版本。 | |||||
*/ | |||||
inline switch_scheduler_awaitor via(scheduler_t* sch) noexcept | inline switch_scheduler_awaitor via(scheduler_t* sch) noexcept | ||||
{ | { | ||||
return { sch }; | return { sch }; |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
timer_manager::timer_manager() | timer_manager::timer_manager() | ||||
{ | { | ||||
_added_timers.reserve(128); | _added_timers.reserve(128); |
#pragma once | #pragma once | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#endif //DOXYGEN_SKIP_PROPERTY | |||||
struct timer_manager; | struct timer_manager; | ||||
typedef std::shared_ptr<timer_manager> timer_mgr_ptr; | typedef std::shared_ptr<timer_manager> timer_mgr_ptr; | ||||
typedef std::weak_ptr<timer_manager> timer_mgr_wptr; | typedef std::weak_ptr<timer_manager> timer_mgr_wptr; |
#include <concepts> | #include <concepts> | ||||
#endif | #endif | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#if RESUMEF_ENABLE_CONCEPT | #if RESUMEF_ENABLE_CONCEPT |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace traits | namespace traits | ||||
{ | { |
#include "../librf.h" | #include "../librf.h" | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
using any_t = std::any; | using any_t = std::any; | ||||
using std::any_cast; | using std::any_cast; | ||||
//最最重要的,要统一ranged when_any的返回值,还得做一个运行时通过下标设置std::variant<>的东西 | //最最重要的,要统一ranged when_any的返回值,还得做一个运行时通过下标设置std::variant<>的东西 | ||||
//std::any除了内存布局不太理想,其他方面几乎没缺点(在此应用下) | //std::any除了内存布局不太理想,其他方面几乎没缺点(在此应用下) | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | |||||
using when_any_pair = std::pair<intptr_t, any_t>; | using when_any_pair = std::pair<intptr_t, any_t>; | ||||
using when_any_pair_ptr = std::shared_ptr<when_any_pair>; | using when_any_pair_ptr = std::shared_ptr<when_any_pair>; | ||||
#ifndef DOXYGEN_SKIP_PROPERTY | #ifndef DOXYGEN_SKIP_PROPERTY | ||||
inline namespace when_v2 | inline namespace when_v2 | ||||
{ | { | ||||
#else | |||||
struct when | |||||
{ | |||||
#endif | #endif | ||||
template<_WhenTaskT... _Awaitable | template<_WhenTaskT... _Awaitable |
#pragma once | #pragma once | ||||
RESUMEF_NS | |||||
namespace resumef | |||||
{ | { | ||||
struct yield_awaitor | struct yield_awaitor | ||||
{ | { |