更新
This commit is contained in:
+5
-6
@@ -1,20 +1,19 @@
|
||||
#pragma once
|
||||
#include "../export/export.h"
|
||||
#include "export/export.h"
|
||||
#include "global.hpp"
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include "time_thread/export/export.h"
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <proxy/proxy.h>
|
||||
|
||||
namespace aethera::frame_policy {
|
||||
using Timer_Id = std::uint64_t;
|
||||
using Timer_Callback = std::function<void()>;
|
||||
using Timer_Id = aethera::Timer_Id;
|
||||
using Timer_Callback = aethera::Timer_Callback;
|
||||
struct Frame : facade_builder::build {};
|
||||
using Frame_Completion = std::function<void(proxy<Frame>&)>;
|
||||
using Render_Completion = std::function<void(proxy<Frame>&, std::exception_ptr)>;
|
||||
struct Scene : facade_builder::add_convention<_create_frame, proxy<Frame>()>::add_convention<_render, Render_Scene_Result(proxy<Frame>&, Render_Completion)>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
struct Sink : facade_builder::add_convention<_send, void(proxy<Frame>&, Frame_Completion)>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
struct Timer_Service : facade_builder::add_convention<_schedule_every, Timer_Id(std::chrono::nanoseconds, Timer_Callback)>::add_convention<_cancel, void(Timer_Id, Timer_Callback)>::add_convention<_reschedule, void(Timer_Id, std::chrono::nanoseconds)>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
using Timer_Service = time_thread::Timer_Service_Frame_Facade;
|
||||
proxy<Timer_Service> make_timer_service();
|
||||
} // namespace aethera::frame_policy
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "Frame_Policy.hpp"
|
||||
#include "rely_facade.h"
|
||||
#include "time_thread/src/Timer_Service_Model.hpp"
|
||||
#include "../rely_facade.h"
|
||||
#include "time_thread/export/export.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
namespace aethera {
|
||||
proxy<frame_policy::Timer_Service> frame_policy::make_timer_service() { return time_thread::make_timer_service_proxy<frame_policy::Timer_Service>(make_steady_timer_time_source()); }
|
||||
proxy<frame_policy::Timer_Service> frame_policy::make_timer_service() { return time_thread::make_timer_service(); }
|
||||
namespace {
|
||||
auto capacity_fps(const Sliding_Statistics& statistics) noexcept -> std::optional<double> {
|
||||
const double average = statistics.summary().average;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "Frame_Policy.hpp"
|
||||
#include "rely_facade.h"
|
||||
#include "../rely_facade.h"
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function(aethera_kernel_add_module target module_name)
|
||||
set(module_dir "${Aethera_Kernel_module_dir}/${module_name}")
|
||||
append_glob_source(module_sources "${module_dir}/src" "${module_dir}/export")
|
||||
append_glob_source(module_sources "${module_dir}/src" "${module_dir}/export" "${module_dir}/rely_facade.h")
|
||||
add_library(${target} STATIC ${module_sources})
|
||||
target_include_directories(${target} PUBLIC "$<BUILD_INTERFACE:${Aethera_Kernel_module_dir}>")
|
||||
target_link_libraries(${target} PUBLIC Aethera_Kernel_Core ${ARGN})
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include "task_flow/export/export.h"
|
||||
|
||||
namespace aethera::renderable {
|
||||
using Task_Graph = task_flow::Task_Graph_Build_Facade;
|
||||
proxy<Task_Graph> make_task_graph(std::string name);
|
||||
} // namespace aethera::renderable
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
#include "global.hpp"
|
||||
#include "task_flow/export/export.h"
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
#include <proxy/proxy.h>
|
||||
#include <string>
|
||||
|
||||
namespace aethera::renderable {
|
||||
struct Task_Graph : facade_builder::add_convention<_add, std::expected<proxy<task_flow::Task_Node>, aethera::Add_Task_Graph_Result>(std::string, std::function<void()>)>::add_convention<_component, proxy<task_flow::Task_Graph_Component>()>::add_convention<_clear, void()>::add_convention<_empty, bool() const noexcept>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
proxy<Task_Graph> make_task_graph(std::string name);
|
||||
} // namespace aethera::renderable
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "renderable.hpp"
|
||||
#include "task_flow/src/Task_Graph_Model.hpp"
|
||||
#include "task_flow/export/export.h"
|
||||
#include <utility>
|
||||
|
||||
namespace aethera {
|
||||
proxy<renderable::Task_Graph> renderable::make_task_graph(std::string name) { return task_flow::make_task_graph<renderable::Task_Graph>(std::move(name)); }
|
||||
proxy<renderable::Task_Graph> renderable::make_task_graph(std::string name) { return task_flow::make_task_graph(std::move(name)); }
|
||||
} // namespace aethera
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "model/Model.hpp"
|
||||
#include "rely_facade.h"
|
||||
#include "../rely_facade.h"
|
||||
namespace aethera {
|
||||
template <typename Self> struct Renderable : Model_Layer<Root> {
|
||||
using Renderable_Type = Self;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "renderable/src/renderable.hpp"
|
||||
#include "scene/src/rely_facade.h"
|
||||
#include "scene/rely_facade.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "global.hpp"
|
||||
#include "task_flow/export/export.h"
|
||||
#include <proxy/proxy.h>
|
||||
|
||||
namespace aethera::scene {
|
||||
using Task_Graph = task_flow::Task_Graph_Compose_Facade;
|
||||
proxy<Task_Graph> make_task_graph(std::string name);
|
||||
struct Renderable : facade_builder::add_convention<_advance, void()>::add_convention<_taskflow, proxy<task_flow::Task_Graph_Component>()>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
} // namespace aethera::scene
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Scene.hpp"
|
||||
#include "task_flow/src/Task_Graph_Model.hpp"
|
||||
#include "task_flow/export/export.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
@@ -7,7 +7,7 @@ namespace aethera {
|
||||
namespace detail {
|
||||
struct Scene_Frame {};
|
||||
}
|
||||
proxy<scene::Task_Graph> scene::make_task_graph(std::string name) { return task_flow::make_task_graph<scene::Task_Graph>(std::move(name)); }
|
||||
proxy<scene::Task_Graph> scene::make_task_graph(std::string name) { return task_flow::make_task_graph(std::move(name)); }
|
||||
Scene::Private::Private() = default;
|
||||
proxy<frame_policy::Frame> Scene::Private::create_frame() {
|
||||
return pro::make_proxy<frame_policy::Frame, detail::Scene_Frame>();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#include "../export/export.h"
|
||||
#include "frame_policy/src/rely_facade.h"
|
||||
#include "frame_policy/rely_facade.h"
|
||||
#include "model/Model.hpp"
|
||||
#include "relation/Dag.hpp"
|
||||
#include <functional>
|
||||
#include <proxy/proxy.h>
|
||||
#include "rely_facade.h"
|
||||
#include "../rely_facade.h"
|
||||
namespace aethera {
|
||||
struct Scene_Renderable_Dag {};
|
||||
/* Scene 通过 Tag + Owned_Dag 在类型系统中表达其对 Renderable DAG 的唯一所有权。 */
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
#include "global.hpp"
|
||||
#include "task_flow/export/export.h"
|
||||
#include <expected>
|
||||
#include <proxy/proxy.h>
|
||||
#include <string>
|
||||
|
||||
namespace aethera::scene {
|
||||
struct Task_Graph : facade_builder::add_convention<_component, proxy<task_flow::Task_Graph_Component>()>::add_convention<_compose, std::expected<proxy<task_flow::Task_Node>, aethera::Compose_Task_Graph_Result>(std::string, proxy<task_flow::Task_Graph_Component>&)>::add_convention<_precede, aethera::Precede_Task_Graph_Result(proxy<task_flow::Task_Node>&, proxy<task_flow::Task_Node>&)>::add_convention<_empty, bool() const noexcept>::add_convention<_run, aethera::Run_Taskflow_Result(aethera::Taskflow_Completion)>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
proxy<Task_Graph> make_task_graph(std::string name);
|
||||
struct Renderable : facade_builder::add_convention<_advance, void()>::add_convention<_taskflow, proxy<task_flow::Task_Graph_Component>()>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
} // namespace aethera::scene
|
||||
@@ -2,8 +2,10 @@
|
||||
#include "global.hpp"
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
#include <proxy/proxy.h>
|
||||
#include <string>
|
||||
|
||||
namespace aethera {
|
||||
enum struct Add_Task_Graph_Result : std::uint8_t { work_missing };
|
||||
@@ -21,5 +23,10 @@ using Taskflow_Exception_Boundary = std::function<void(std::exception_ptr)>;
|
||||
namespace task_flow {
|
||||
struct Task_Node : facade_builder::add_skill<pro::skills::rtti>::build {};
|
||||
struct Task_Graph_Component : facade_builder::add_skill<pro::skills::rtti>::build {};
|
||||
struct Task_Graph_Common_Facade : facade_builder::add_convention<_component, proxy<Task_Graph_Component>()>::add_convention<_empty, bool() const noexcept>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
struct Task_Graph_Build_Facade : facade_builder::add_facade_with_substitution<Task_Graph_Common_Facade>::add_convention<_add, std::expected<proxy<Task_Node>, Add_Task_Graph_Result>(std::string, std::function<void()>)>::add_convention<_clear, void()>::build {};
|
||||
struct Task_Graph_Compose_Facade : facade_builder::add_facade_with_substitution<Task_Graph_Common_Facade>::add_convention<_compose, std::expected<proxy<Task_Node>, Compose_Task_Graph_Result>(std::string, proxy<Task_Graph_Component>&)>::add_convention<_precede, Precede_Task_Graph_Result(proxy<Task_Node>&, proxy<Task_Node>&)>::add_convention<_run, Run_Taskflow_Result(Taskflow_Completion)>::build {};
|
||||
struct Task_Graph_Facade : facade_builder::add_facade_with_substitution<Task_Graph_Build_Facade>::add_facade_with_substitution<Task_Graph_Compose_Facade>::build {};
|
||||
proxy<Task_Graph_Facade> make_task_graph(std::string name);
|
||||
} // namespace task_flow
|
||||
} // namespace aethera
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
@@ -26,5 +26,4 @@ private:
|
||||
std::shared_ptr<aethera::Task_Graph> graph; /* 所有消费 facade 共享的唯一权威任务图。 */
|
||||
};
|
||||
|
||||
template <typename Facade> proxy<Facade> make_task_graph(std::string name) { return make_model_proxy<Facade, Task_Graph_Model>(std::make_shared<aethera::Task_Graph>(std::move(name))); }
|
||||
} // namespace aethera::task_flow
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#pragma once
|
||||
namespace aethera::task_flow {}
|
||||
@@ -34,4 +34,5 @@ Precede_Task_Graph_Result Task_Graph_Model::Private::precede(proxy<Task_Node>& b
|
||||
void Task_Graph_Model::Private::clear() { graph->clear(); }
|
||||
bool Task_Graph_Model::Private::empty() const noexcept { return graph->empty(); }
|
||||
Run_Taskflow_Result Task_Graph_Model::Private::run(Taskflow_Completion completion) { return run_taskflow(*graph, std::move(completion)); }
|
||||
proxy<Task_Graph_Facade> make_task_graph(std::string name) { return make_model_proxy<Task_Graph_Facade, Task_Graph_Model>(std::make_shared<aethera::Task_Graph>(std::move(name))); }
|
||||
} // namespace aethera::task_flow
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "task_flow/src/Task_Runtime.hpp"
|
||||
#include "../src/detail/Taskflow_Execution.ipp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <chrono>
|
||||
@@ -15,6 +14,8 @@
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
static_assert(std::is_convertible_v<aethera::proxy<aethera::task_flow::Task_Graph_Facade>&&, aethera::proxy<aethera::task_flow::Task_Graph_Build_Facade>>);
|
||||
static_assert(std::is_convertible_v<aethera::proxy<aethera::task_flow::Task_Graph_Facade>&&, aethera::proxy<aethera::task_flow::Task_Graph_Compose_Facade>>);
|
||||
|
||||
using Run_Without_Observation = aethera::Run_Taskflow_Result(*)(
|
||||
aethera::Task_Graph&,
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
#pragma once
|
||||
#include "global.hpp"
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <proxy/proxy.h>
|
||||
|
||||
namespace aethera {
|
||||
using Timer_Id = std::uint64_t;
|
||||
using Timer_Callback = std::function<void()>;
|
||||
using Timer_Time_Point = std::chrono::steady_clock::time_point;
|
||||
enum struct Make_Timer_Service_Result : std::uint8_t { time_source_unavailable };
|
||||
namespace time_thread {
|
||||
struct Timer_Service_Frame_Facade : facade_builder::add_convention<_schedule_every, Timer_Id(std::chrono::nanoseconds, Timer_Callback)>::add_convention<_cancel, void(Timer_Id, Timer_Callback)>::add_convention<_reschedule, void(Timer_Id, std::chrono::nanoseconds)>::support_relocation<pro::constraint_level::nothrow>::build {};
|
||||
struct Timer_Service_Facade : facade_builder::add_facade_with_substitution<Timer_Service_Frame_Facade>::add_convention<_schedule_after, Timer_Id(std::chrono::nanoseconds, Timer_Callback)>::build {};
|
||||
proxy<Timer_Service_Facade> make_timer_service();
|
||||
} // namespace time_thread
|
||||
} // namespace aethera
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
@@ -200,6 +200,7 @@ void time_thread::Timer_Service_Model::Private::cancel(Timer_Id id, Timer_Callba
|
||||
std::shared_ptr<time_thread::Thread_Timer_Service_State> time_thread::make_timer_service_state(proxy<Timer_Time_Source> time_source) { return std::make_shared<Thread_Timer_Service_State>(std::move(time_source)); }
|
||||
|
||||
proxy<Timer_Time_Source> make_steady_timer_time_source() { return make_model_proxy<Timer_Time_Source, Steady_Timer_Time_Source>(); }
|
||||
proxy<time_thread::Timer_Service_Facade> time_thread::make_timer_service() { return make_model_proxy_shared<Timer_Service_Facade, Timer_Service_Model>(make_timer_service_state(make_steady_timer_time_source())); }
|
||||
|
||||
std::expected<proxy<Timer_Service>, Make_Timer_Service_Result>
|
||||
make_timer_service(proxy<Timer_Time_Source> time_source) {
|
||||
@@ -207,6 +208,6 @@ make_timer_service(proxy<Timer_Time_Source> time_source) {
|
||||
return std::unexpected(
|
||||
Make_Timer_Service_Result::time_source_unavailable);
|
||||
}
|
||||
return time_thread::make_timer_service_proxy<Timer_Service>(std::move(time_source));
|
||||
return make_model_proxy_shared<Timer_Service, time_thread::Timer_Service_Model>(time_thread::make_timer_service_state(std::move(time_source)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,21 +10,7 @@
|
||||
#include <proxy/proxy.h>
|
||||
|
||||
namespace aethera {
|
||||
struct Timer_Service : facade_builder
|
||||
::add_convention<
|
||||
_schedule_every,
|
||||
Timer_Id(std::chrono::nanoseconds, Timer_Callback)>
|
||||
::add_convention<
|
||||
_cancel,
|
||||
void(Timer_Id, Timer_Callback)>
|
||||
::add_convention<
|
||||
_schedule_after,
|
||||
Timer_Id(std::chrono::nanoseconds, Timer_Callback)>
|
||||
::add_convention<
|
||||
_reschedule,
|
||||
void(Timer_Id, std::chrono::nanoseconds)>
|
||||
::support_relocation<pro::constraint_level::nothrow>
|
||||
::build {};
|
||||
using Timer_Service = time_thread::Timer_Service_Facade;
|
||||
|
||||
[[nodiscard]] std::expected<proxy<Timer_Service>, Make_Timer_Service_Result>
|
||||
make_timer_service(proxy<Timer_Time_Source> time_source);
|
||||
|
||||
@@ -23,5 +23,4 @@ private:
|
||||
};
|
||||
|
||||
std::shared_ptr<Thread_Timer_Service_State> make_timer_service_state(proxy<Timer_Time_Source> time_source);
|
||||
template <typename Facade> proxy<Facade> make_timer_service_proxy(proxy<Timer_Time_Source> time_source) { return make_model_proxy_shared<Facade, Timer_Service_Model>(make_timer_service_state(std::move(time_source))); }
|
||||
} // namespace aethera::time_thread
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#pragma once
|
||||
namespace aethera::time_thread {}
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "time_thread/src/Timer_Service.hpp"
|
||||
#include "time_thread/src/Timer_Time_Source.hpp"
|
||||
#include "../src/detail/Timer_Scheduler.hpp"
|
||||
#include <type_traits>
|
||||
#include "model/Model.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@@ -11,6 +12,7 @@
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
static_assert(std::is_convertible_v<aethera::proxy<aethera::time_thread::Timer_Service_Facade>&&, aethera::proxy<aethera::time_thread::Timer_Service_Frame_Facade>>);
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
template<typename Service>
|
||||
|
||||
Reference in New Issue
Block a user