#include "spinlock.h" | #include "spinlock.h" | ||||
#include "future.h" | #include "future.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
template<class _Ty> | template<class _Ty> | ||||
struct awaitable_impl_t | struct awaitable_impl_t |
#include "_awaker.h" | #include "_awaker.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
| | ||||
#pragma once | #pragma once | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
template <typename T> | template <typename T> | ||||
struct counted_ptr | struct counted_ptr |
#include <assert.h> | #include <assert.h> | ||||
#include <experimental/coroutine> | #include <experimental/coroutine> | ||||
#define LIB_RESUMEF_VERSION 200102 // 2.1.2 | |||||
#define LIB_RESUMEF_VERSION 200103 // 2.1.3 | |||||
namespace resumef | |||||
#if defined(RESUMEF_MODULE_EXPORT) | |||||
#define RESUMEF_NS export namespace resumef | |||||
#else | |||||
#define RESUMEF_NS namespace resumef | |||||
#endif | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct scheduler_t; | struct scheduler_t; | ||||
extern std::atomic<intptr_t> g_resumef_state_id; | extern std::atomic<intptr_t> g_resumef_state_id; | ||||
#endif | #endif | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
template<class T> | template<class T> | ||||
struct remove_cvref | struct remove_cvref |
#include "awaitable.h" | #include "awaitable.h" | ||||
#include "state.inl" | #include "state.inl" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#include "_awaker.h" | #include "_awaker.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
enum struct error_code | enum struct error_code | ||||
{ | { |
#include "state.h" | #include "state.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
template<class _Ty> | template<class _Ty> | ||||
struct future_t | struct future_t |
#pragma push_macro("new") | #pragma push_macro("new") | ||||
#undef new | #undef new | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
template <typename _Ty, typename promise_type> | template <typename _Ty, typename promise_type> | ||||
struct generator_iterator; | struct generator_iterator; |
#include "awaitable.h" | #include "awaitable.h" | ||||
#include "state.inl" | #include "state.inl" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#include "_awaker.h" | #include "_awaker.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma push_macro("new") | #pragma push_macro("new") | ||||
#undef new | #undef new | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct suspend_on_initial; | struct suspend_on_initial; | ||||
struct suspend_on_final; | struct suspend_on_final; |
#pragma once | #pragma once | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct suspend_on_initial | struct suspend_on_initial | ||||
{ | { |
#include "scheduler.h" | #include "scheduler.h" | ||||
#include <assert.h> | #include <assert.h> | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
task_base_t::~task_base_t() | task_base_t::~task_base_t() | ||||
{ | { |
#include "future.h" | #include "future.h" | ||||
#include "promise.h" | #include "promise.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct task_base_t; | struct task_base_t; | ||||
std::atomic<intptr_t> g_resumef_state_id = 0; | std::atomic<intptr_t> g_resumef_state_id = 0; | ||||
#endif | #endif | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
static const char * future_error_string[(size_t)error_code::max__] | |||||
const char * future_error_string[(size_t)error_code::max__] | |||||
{ | { | ||||
"none", | "none", | ||||
"not_ready", | "not_ready", | ||||
"timer_canceled", | "timer_canceled", | ||||
}; | }; | ||||
static char sz_future_error_buffer[256]; | |||||
char sz_future_error_buffer[256]; | |||||
const char * get_error_string(error_code fe, const char * classname) | const char * get_error_string(error_code fe, const char * classname) | ||||
{ | { |
#include "utils.h" | #include "utils.h" | ||||
#include "timer.h" | #include "timer.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct local_scheduler; | struct local_scheduler; | ||||
void run(); | void run(); | ||||
//void break_all(); | //void break_all(); | ||||
template<class _Ty, typename = std::enable_if_t<std::is_callable_v<_Ty> || is_future_v<_Ty> || is_generator_v<_Ty> >> | |||||
template<class _Ty, typename = std::enable_if_t<is_callable_v<_Ty> || is_future_v<_Ty> || is_generator_v<_Ty> >> | |||||
inline void operator + (_Ty&& t_) | inline void operator + (_Ty&& t_) | ||||
{ | { | ||||
if constexpr (std::is_callable<_Ty>::value) | |||||
if constexpr (is_callable_v<_Ty>) | |||||
new_task(new ctx_task_t<_Ty>(std::forward<_Ty>(t_))); | new_task(new ctx_task_t<_Ty>(std::forward<_Ty>(t_))); | ||||
else | else | ||||
new_task(new task_t<_Ty>(std::forward<_Ty>(t_))); | new_task(new task_t<_Ty>(std::forward<_Ty>(t_))); |
#include "awaitable.h" | #include "awaitable.h" | ||||
#include "sleep.h" | #include "sleep.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
future_t<> sleep_until_(const std::chrono::system_clock::time_point& tp_, scheduler_t& scheduler_) | future_t<> sleep_until_(const std::chrono::system_clock::time_point& tp_, scheduler_t& scheduler_) | ||||
{ | { |
// | // | ||||
#pragma once | #pragma once | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct scheduler_t; | struct scheduler_t; | ||||
#include "def.h" | #include "def.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct spinlock | struct spinlock | ||||
{ | { |
#include "scheduler.h" | #include "scheduler.h" | ||||
#include <assert.h> | #include <assert.h> | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
state_base_t::~state_base_t() | state_base_t::~state_base_t() | ||||
{ | { |
#include "counted_ptr.h" | #include "counted_ptr.h" | ||||
#include <iostream> | #include <iostream> | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct state_base_t | struct state_base_t | ||||
{ | { |
#pragma once | #pragma once | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
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) |
#include "timer.h" | #include "timer.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
timer_manager::timer_manager() | timer_manager::timer_manager() |
#include "def.h" | #include "def.h" | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
struct timer_manager; | struct timer_manager; | ||||
typedef std::shared_ptr<timer_manager> timer_mgr_ptr; | typedef std::shared_ptr<timer_manager> timer_mgr_ptr; |
#pragma once | #pragma once | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
template<class _PromiseT> | template<class _PromiseT> | ||||
struct is_promise : std::false_type {}; | struct is_promise : std::false_type {}; |
#pragma once | #pragma once | ||||
namespace std | |||||
RESUMEF_NS | |||||
{ | { | ||||
template<typename _Function> | template<typename _Function> | ||||
inline auto _IsCallable(_Function && _Func, int) -> decltype(_Func(), true_type()) | |||||
inline auto _IsCallable(_Function && _Func, int) -> decltype(_Func(), std::true_type()) | |||||
{ | { | ||||
(_Func); | (_Func); | ||||
return true_type(); | |||||
return std::true_type(); | |||||
} | } | ||||
template<typename _Function> | template<typename _Function> | ||||
inline false_type _IsCallable(_Function &&, ...) | |||||
inline std::false_type _IsCallable(_Function &&, ...) | |||||
{ | { | ||||
return false_type(); | |||||
return std::false_type(); | |||||
} | } | ||||
template<typename _Function> | template<typename _Function> |
#include "when.h" | #include "when.h" | ||||
#include <assert.h> | #include <assert.h> | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#pragma once | #pragma once | ||||
#include <any> | #include <any> | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
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除了内存布局不太理想,其他方面几乎没缺点(在此应用下) | ||||
namespace resumef | |||||
RESUMEF_NS | |||||
{ | { | ||||
namespace detail | namespace detail | ||||
{ | { |
#include <experimental/resumable> | #include <experimental/resumable> | ||||
#include <experimental/generator> | #include <experimental/generator> | ||||
#include <optional> | #include <optional> | ||||
#include "async_wrapper.hpp" | |||||
extern void resumable_main_yield_return(); | extern void resumable_main_yield_return(); | ||||
extern void resumable_main_timer(); | extern void resumable_main_timer(); |
| | ||||
Microsoft Visual Studio Solution File, Format Version 12.00 | Microsoft Visual Studio Solution File, Format Version 12.00 | ||||
# Visual Studio 15 | |||||
VisualStudioVersion = 15.0.27004.2006 | |||||
# Visual Studio Version 16 | |||||
VisualStudioVersion = 16.0.29814.53 | |||||
MinimumVisualStudioVersion = 10.0.40219.1 | MinimumVisualStudioVersion = 10.0.40219.1 | ||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "librf", "librf.vcxproj", "{C1D4A6BD-592F-4E48-8178-7C87219BF80E}" | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "librf", "librf.vcxproj", "{C1D4A6BD-592F-4E48-8178-7C87219BF80E}" | ||||
EndProject | EndProject | ||||
Global | Global | ||||
GlobalSection(Performance) = preSolution | |||||
HasPerformanceSessions = true | |||||
EndGlobalSection | |||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|x64 = Debug|x64 | Debug|x64 = Debug|x64 | ||||
Debug|x86 = Debug|x86 | Debug|x86 = Debug|x86 | ||||
GlobalSection(Performance) = preSolution | GlobalSection(Performance) = preSolution | ||||
HasPerformanceSessions = true | HasPerformanceSessions = true | ||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(Performance) = preSolution | |||||
HasPerformanceSessions = true | |||||
EndGlobalSection | |||||
EndGlobal | EndGlobal |
<CLanguageStandard>c11</CLanguageStandard> | <CLanguageStandard>c11</CLanguageStandard> | ||||
<CppLanguageStandard>c++1y</CppLanguageStandard> | <CppLanguageStandard>c++1y</CppLanguageStandard> | ||||
<DisableSpecificWarnings>4834</DisableSpecificWarnings> | <DisableSpecificWarnings>4834</DisableSpecificWarnings> | ||||
<EnableModules>true</EnableModules> | |||||
</ClCompile> | </ClCompile> | ||||
<Link> | <Link> | ||||
<SubSystem>Console</SubSystem> | <SubSystem>Console</SubSystem> |