This commit is contained in:
sha512sum 2024-06-11 08:38:57 +00:00
parent da0bcfbb63
commit 6cdb8b0ffd

View file

@ -2,7 +2,6 @@
#include <cserver/engine/basic/task_processor.hpp> #include <cserver/engine/basic/task_processor.hpp>
#include <cserver/engine/coroutine.hpp> #include <cserver/engine/coroutine.hpp>
#include <utempl/utils.hpp> #include <utempl/utils.hpp>
#include <thread>
namespace cserver { namespace cserver {
@ -73,14 +72,12 @@ inline constexpr auto GetInitFlagFor(auto&... args) -> InitFlag& {
}; };
template <typename InitFlag, utempl::Tuple Tuple> template <typename InitFlag, utempl::Tuple Tuple>
inline constexpr auto TransformDependencyGraphToInited(auto&&... args) { constexpr auto TransformDependencyGraphToTupleWithDependenciesToInitedFlagChanges(auto&&... args) {
return [&]<std::size_t... Is>(std::index_sequence<Is...>) { return utempl::Map(utempl::PackConstexprWrapper<Tuple>(), [&]<auto Array>(utempl::Wrapper<Array>) {
return utempl::Tuple{[&]<auto Array>(utempl::Wrapper<Array>){ return utempl::Map(utempl::PackConstexprWrapper<Array, utempl::Tuple<>>(), [&](auto elem) {
return [&]<std::size_t... IIs>(std::index_sequence<IIs...>){ return &GetInitFlagFor<InitFlag, static_cast<std::size_t>(elem)>(args...);
return std::array<InitFlag*, Array.size()>{&GetInitFlagFor<InitFlag, Array[IIs]>(args...)...}; }, utempl::kType<std::array<InitFlag*, Array.size()>>);
}(std::make_index_sequence<Array.size()>()); });
}(utempl::Wrapper<Get<Is>(Tuple)>{})...};
}(std::make_index_sequence<utempl::kTupleSize<decltype(Tuple)>>());
}; };
struct AsyncConditionVariable { struct AsyncConditionVariable {
@ -124,7 +121,7 @@ inline constexpr auto InitComponents(T& ccontext) -> void {
static auto& context = ccontext; static auto& context = ccontext;
static auto& taskProcessor = context.template FindComponent<kBasicTaskProcessorName>(); static auto& taskProcessor = context.template FindComponent<kBasicTaskProcessorName>();
static auto& ioContext = taskProcessor.ioContext; static auto& ioContext = taskProcessor.ioContext;
static utempl::Tuple inited = TransformDependencyGraphToInited<AsyncConditionVariable, DependencyGraph>(ioContext); static utempl::Tuple inited = TransformDependencyGraphToTupleWithDependenciesToInitedFlagChanges<AsyncConditionVariable, DependencyGraph>(ioContext);
auto work = make_work_guard(ioContext); auto work = make_work_guard(ioContext);
[]<std::size_t... Is>(std::index_sequence<Is...>){ []<std::size_t... Is>(std::index_sequence<Is...>){
(boost::asio::co_spawn(ioContext, []() -> cserver::Task<> { (boost::asio::co_spawn(ioContext, []() -> cserver::Task<> {