2 #include <samchon/API.hpp> 4 #include <samchon/templates/parallel/ParallelSystem.hpp> 6 #include <samchon/templates/distributed/DSInvokeHistory.hpp> 7 #include <samchon/templates/distributed/base/DistributedSystemArrayBase.hpp> 8 #include <samchon/templates/distributed/base/DistributedProcessBase.hpp> 68 for (
auto it = _Get_progress_list().begin(); it != _Get_progress_list().end(); it++)
71 std::shared_ptr<protocol::Invoke> invoke = it->second.first;
72 std::shared_ptr<slave::InvokeHistory> history = it->second.second;
75 _Send_back_history(invoke, history);
103 auto _Compute_average_elapsed_time()
const ->
double 106 size_t denominator = 0;
108 for (
auto it = _Get_history_list().begin(); it != _Get_history_list().end(); it++)
110 std::shared_ptr<DSInvokeHistory> history = std::dynamic_pointer_cast<
DSInvokeHistory>(it->second);
111 if (history ==
nullptr)
116 sum += elapsed_time / ((base::DistributedProcessBase*)(history->getProcess()))->getResource();
120 if (denominator == 0)
123 return sum / denominator;
130 virtual void replyData(std::shared_ptr<protocol::Invoke> invoke)
override 133 auto process_map = ((base::DistributedSystemArrayBase*)system_array_)->getProcessMap();
134 for (
auto it = process_map.begin(); it != process_map.end(); it++)
135 ((base::DistributedProcessBase*)(it->second.get()))->replyData(invoke);
141 virtual void _Send_back_history(std::shared_ptr<protocol::Invoke> invoke, std::shared_ptr<slave::InvokeHistory> $history)
143 std::shared_ptr<DSInvokeHistory> history = std::dynamic_pointer_cast<
DSInvokeHistory>($history);
144 if (history !=
nullptr)
147 ((base::DistributedProcessBase*)(history->getProcess()))->sendData(invoke, history->getWeight());
151 super::_Send_back_history(invoke, history);
155 virtual void _Report_history(std::shared_ptr<library::XML> xml)
override 157 if (xml->hasProperty(
"_Piece_first") ==
true)
162 super::_Report_history(xml);
173 history->construct(xml);
176 auto progress_it = _Get_progress_list().find(history->getUID());
177 if (progress_it == _Get_progress_list().end())
180 history->weight_ = std::dynamic_pointer_cast<
DSInvokeHistory>(progress_it->second.second)->getWeight();
183 _Get_progress_list().erase(progress_it);
184 _Get_history_list().emplace(history->getUID(), history);
187 if (history->getProcess() !=
nullptr)
188 ((base::DistributedProcessBase*)(history->getProcess()))->_Report_history(history);
191 ((parallel::base::ParallelSystemArrayBase*)system_array_)->_Complete_history(history);
auto computeElapsedTime() const -> long long
virtual void replyData(std::shared_ptr< protocol::Invoke > invoke) override
virtual auto createChild(std::shared_ptr< library::XML >) -> external::ExternalSystemRole *override
virtual void replyData(std::shared_ptr< protocol::Invoke > invoke) override