@@ -3,7 +3,7 @@ | |||
#include "spinlock.h" | |||
#include "future.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -1,6 +1,6 @@ | |||
#pragma once | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
template<class _Ty> | |||
struct awaitable_impl_t |
@@ -2,7 +2,7 @@ | |||
#include "_awaker.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -1,7 +1,7 @@ | |||
| |||
#pragma once | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
template <typename T> | |||
struct counted_ptr |
@@ -14,9 +14,15 @@ | |||
#include <assert.h> | |||
#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; | |||
@@ -55,7 +61,7 @@ extern std::atomic<intptr_t> g_resumef_evtctx_count; | |||
extern std::atomic<intptr_t> g_resumef_state_id; | |||
#endif | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
template<class T> | |||
struct remove_cvref |
@@ -4,7 +4,7 @@ | |||
#include "awaitable.h" | |||
#include "state.inl" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -2,7 +2,7 @@ | |||
#include "_awaker.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -1,6 +1,6 @@ | |||
#pragma once | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
enum struct error_code | |||
{ |
@@ -3,7 +3,7 @@ | |||
#include "state.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
template<class _Ty> | |||
struct future_t |
@@ -9,7 +9,7 @@ | |||
#pragma push_macro("new") | |||
#undef new | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
template <typename _Ty, typename promise_type> | |||
struct generator_iterator; |
@@ -4,7 +4,7 @@ | |||
#include "awaitable.h" | |||
#include "state.inl" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -2,7 +2,7 @@ | |||
#include "_awaker.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -4,7 +4,7 @@ | |||
#pragma push_macro("new") | |||
#undef new | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct suspend_on_initial; | |||
struct suspend_on_final; |
@@ -1,6 +1,6 @@ | |||
#pragma once | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct suspend_on_initial | |||
{ |
@@ -3,7 +3,7 @@ | |||
#include "scheduler.h" | |||
#include <assert.h> | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
task_base_t::~task_base_t() | |||
{ |
@@ -4,7 +4,7 @@ | |||
#include "future.h" | |||
#include "promise.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct task_base_t; | |||
@@ -9,9 +9,9 @@ std::atomic<intptr_t> g_resumef_evtctx_count = 0; | |||
std::atomic<intptr_t> g_resumef_state_id = 0; | |||
#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", | |||
"not_ready", | |||
@@ -21,7 +21,7 @@ namespace resumef | |||
"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) | |||
{ |
@@ -9,7 +9,7 @@ | |||
#include "utils.h" | |||
#include "timer.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct local_scheduler; | |||
@@ -39,10 +39,10 @@ namespace resumef | |||
void run(); | |||
//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_) | |||
{ | |||
if constexpr (std::is_callable<_Ty>::value) | |||
if constexpr (is_callable_v<_Ty>) | |||
new_task(new ctx_task_t<_Ty>(std::forward<_Ty>(t_))); | |||
else | |||
new_task(new task_t<_Ty>(std::forward<_Ty>(t_))); |
@@ -3,7 +3,7 @@ | |||
#include "awaitable.h" | |||
#include "sleep.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
future_t<> sleep_until_(const std::chrono::system_clock::time_point& tp_, scheduler_t& scheduler_) | |||
{ |
@@ -4,7 +4,7 @@ | |||
// | |||
#pragma once | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct scheduler_t; | |||
@@ -5,7 +5,7 @@ | |||
#include "def.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct spinlock | |||
{ |
@@ -3,7 +3,7 @@ | |||
#include "scheduler.h" | |||
#include <assert.h> | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
state_base_t::~state_base_t() | |||
{ |
@@ -6,7 +6,7 @@ | |||
#include "counted_ptr.h" | |||
#include <iostream> | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct state_base_t | |||
{ |
@@ -1,6 +1,6 @@ | |||
#pragma once | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
template<class _PromiseT, typename _Enable> | |||
void state_future_t::promise_initial_suspend(coroutine_handle<_PromiseT> handler) |
@@ -1,7 +1,7 @@ | |||
#include "timer.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
timer_manager::timer_manager() |
@@ -3,7 +3,7 @@ | |||
#include "def.h" | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
struct timer_manager; | |||
typedef std::shared_ptr<timer_manager> timer_mgr_ptr; |
@@ -1,6 +1,6 @@ | |||
#pragma once | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
template<class _PromiseT> | |||
struct is_promise : std::false_type {}; |
@@ -1,17 +1,17 @@ | |||
#pragma once | |||
namespace std | |||
RESUMEF_NS | |||
{ | |||
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); | |||
return true_type(); | |||
return std::true_type(); | |||
} | |||
template<typename _Function> | |||
inline false_type _IsCallable(_Function &&, ...) | |||
inline std::false_type _IsCallable(_Function &&, ...) | |||
{ | |||
return false_type(); | |||
return std::false_type(); | |||
} | |||
template<typename _Function> |
@@ -3,7 +3,7 @@ | |||
#include "when.h" | |||
#include <assert.h> | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -1,7 +1,7 @@ | |||
#pragma once | |||
#include <any> | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
using any_t = std::any; | |||
using std::any_cast; | |||
@@ -19,7 +19,7 @@ namespace resumef | |||
//最最重要的,要统一ranged when_any的返回值,还得做一个运行时通过下标设置std::variant<>的东西 | |||
//std::any除了内存布局不太理想,其他方面几乎没缺点(在此应用下) | |||
namespace resumef | |||
RESUMEF_NS | |||
{ | |||
namespace detail | |||
{ |
@@ -3,6 +3,7 @@ | |||
#include <experimental/resumable> | |||
#include <experimental/generator> | |||
#include <optional> | |||
#include "async_wrapper.hpp" | |||
extern void resumable_main_yield_return(); | |||
extern void resumable_main_timer(); |
@@ -1,14 +1,11 @@ | |||
| |||
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 | |||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "librf", "librf.vcxproj", "{C1D4A6BD-592F-4E48-8178-7C87219BF80E}" | |||
EndProject | |||
Global | |||
GlobalSection(Performance) = preSolution | |||
HasPerformanceSessions = true | |||
EndGlobalSection | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|x64 = Debug|x64 | |||
Debug|x86 = Debug|x86 | |||
@@ -34,4 +31,7 @@ Global | |||
GlobalSection(Performance) = preSolution | |||
HasPerformanceSessions = true | |||
EndGlobalSection | |||
GlobalSection(Performance) = preSolution | |||
HasPerformanceSessions = true | |||
EndGlobalSection | |||
EndGlobal |
@@ -110,6 +110,7 @@ | |||
<CLanguageStandard>c11</CLanguageStandard> | |||
<CppLanguageStandard>c++1y</CppLanguageStandard> | |||
<DisableSpecificWarnings>4834</DisableSpecificWarnings> | |||
<EnableModules>true</EnableModules> | |||
</ClCompile> | |||
<Link> | |||
<SubSystem>Console</SubSystem> |