Browse Source

为支持modules做准备

tags/v2.9.7
tearshark 4 years ago
parent
commit
ae954d9131

+ 1
- 1
librf/src/_awaker.h View File

#include "spinlock.h" #include "spinlock.h"
#include "future.h" #include "future.h"
namespace resumef
RESUMEF_NS
{ {
namespace detail namespace detail
{ {

+ 1
- 1
librf/src/awaitable.h View File

#pragma once #pragma once


namespace resumef
RESUMEF_NS
{ {
template<class _Ty> template<class _Ty>
struct awaitable_impl_t struct awaitable_impl_t

+ 1
- 1
librf/src/channel.h View File

#include "_awaker.h" #include "_awaker.h"
namespace resumef
RESUMEF_NS
{ {
namespace detail namespace detail
{ {

+ 1
- 1
librf/src/counted_ptr.h View File

 
#pragma once #pragma once
namespace resumef
RESUMEF_NS
{ {
template <typename T> template <typename T>
struct counted_ptr struct counted_ptr

+ 9
- 3
librf/src/def.h View File

#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

+ 1
- 1
librf/src/event.cpp View File

#include "awaitable.h" #include "awaitable.h"
#include "state.inl" #include "state.inl"
namespace resumef
RESUMEF_NS
{ {
namespace detail namespace detail
{ {

+ 1
- 1
librf/src/event.h View File

#include "_awaker.h" #include "_awaker.h"
namespace resumef
RESUMEF_NS
{ {
namespace detail namespace detail
{ {

+ 1
- 1
librf/src/exception.inl View File

#pragma once #pragma once


namespace resumef
RESUMEF_NS
{ {
enum struct error_code enum struct error_code
{ {

+ 1
- 1
librf/src/future.h View File

#include "state.h" #include "state.h"
namespace resumef
RESUMEF_NS
{ {
template<class _Ty> template<class _Ty>
struct future_t struct future_t

+ 1
- 1
librf/src/generator.h View File

#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;

+ 1
- 1
librf/src/mutex.cpp View File

#include "awaitable.h" #include "awaitable.h"
#include "state.inl" #include "state.inl"
namespace resumef
RESUMEF_NS
{ {
namespace detail namespace detail
{ {

+ 1
- 1
librf/src/mutex.h View File

#include "_awaker.h" #include "_awaker.h"
namespace resumef
RESUMEF_NS
{ {
namespace detail namespace detail
{ {

+ 1
- 1
librf/src/promise.h View File

#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;

+ 1
- 1
librf/src/promise.inl View File

#pragma once #pragma once


namespace resumef
RESUMEF_NS
{ {
struct suspend_on_initial struct suspend_on_initial
{ {

+ 1
- 1
librf/src/rf_task.cpp View File

#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()
{ {

+ 1
- 1
librf/src/rf_task.h View File

#include "future.h" #include "future.h"
#include "promise.h" #include "promise.h"
namespace resumef
RESUMEF_NS
{ {
struct task_base_t; struct task_base_t;

+ 3
- 3
librf/src/scheduler.cpp View File

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)
{ {

+ 3
- 3
librf/src/scheduler.h View File

#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_)));

+ 1
- 1
librf/src/sleep.cpp View File

#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_)
{ {

+ 1
- 1
librf/src/sleep.h View File

// //
#pragma once #pragma once
namespace resumef
RESUMEF_NS
{ {
struct scheduler_t; struct scheduler_t;

+ 1
- 1
librf/src/spinlock.h View File

#include "def.h" #include "def.h"
namespace resumef
RESUMEF_NS
{ {
struct spinlock struct spinlock
{ {

+ 1
- 1
librf/src/state.cpp View File

#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()
{ {

+ 1
- 1
librf/src/state.h View File

#include "counted_ptr.h" #include "counted_ptr.h"
#include <iostream> #include <iostream>
namespace resumef
RESUMEF_NS
{ {
struct state_base_t struct state_base_t
{ {

+ 1
- 1
librf/src/state.inl View File

#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)

+ 1
- 1
librf/src/timer.cpp View File

#include "timer.h" #include "timer.h"
namespace resumef
RESUMEF_NS
{ {
timer_manager::timer_manager() timer_manager::timer_manager()

+ 1
- 1
librf/src/timer.h View File

#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;

+ 1
- 1
librf/src/type_traits.inl View File

#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 {};

+ 5
- 5
librf/src/utils.h View File

#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>

+ 1
- 1
librf/src/when.cpp View File

#include "when.h" #include "when.h"
#include <assert.h> #include <assert.h>
namespace resumef
RESUMEF_NS
{ {
namespace detail namespace detail
{ {

+ 2
- 2
librf/src/when.h View File

#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
{ {

+ 1
- 0
vs_proj/librf.cpp View File

#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();

+ 5
- 5
vs_proj/librf.sln View File

 
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

+ 1
- 0
vs_proj/librf.vcxproj View File

<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>

Loading…
Cancel
Save