2 #include <samchon/API.hpp> 4 #include <samchon/templates/slave/SlaveSystem.hpp> 5 #include <samchon/protocol/IListener.hpp> 7 #include <samchon/templates/parallel/base/ParallelSystemArrayBase.hpp> 8 #include <samchon/templates/distributed/base/DistributedSystemArrayBase.hpp> 9 #include <samchon/templates/distributed/base/DistributedProcessBase.hpp> 12 #include <samchon/HashMap.hpp> 50 :
public virtual slave::SlaveSystem,
54 typedef slave::SlaveSystem super;
56 external::base::ExternalSystemArrayBase *system_array_;
73 this->system_array_ = systemArray;
88 virtual void start() = 0;
96 template <
class SystemArray>
99 return (SystemArray*)system_array_;
105 void _Complete_history(
size_t uid)
107 std::unique_lock<std::mutex> uk(mtx_);
113 if (progress_list_.
has(uid) ==
false)
117 std::shared_ptr<slave::InvokeHistory> history = progress_list_.
get(uid);
121 progress_list_.erase(uid);
124 std::thread(&MediatorSystem::sendData,
this, history->toInvoke()).detach();
128 virtual void _Reply_data(std::shared_ptr<protocol::Invoke> invoke)
override final 130 if (invoke->has(
"_History_uid") ==
true)
134 progress_list_.insert({ history->getUID(), history });
136 if (invoke->has(
"_Piece_first") ==
true)
139 size_t first = invoke->
get(
"_Piece_first")->getValue<
size_t>();
140 size_t last = invoke->get(
"_Piece_last")->getValue<
size_t>();
142 invoke->erase(invoke->end() - 2, invoke->end());
143 ((base::ParallelSystemArrayBase*)system_array_)->sendPieceData(invoke, first, last);
145 else if (invoke->has(
"_Process_name") ==
true)
148 auto ds_system_array = (distributed::base::DistributedSystemArrayBase*)system_array_;
151 const std::string &process_name = invoke->get(
"_Process_name")->getValue<std::string>();
152 if (ds_system_array->hasProcess(process_name) ==
false)
156 auto process = ds_system_array->getProcess(process_name);
157 ((distributed::base::DistributedProcessBase*)(process.get()))->sendData(invoke, 1.0);
165 virtual void replyData(std::shared_ptr<protocol::Invoke> invoke)
override 174 #include <samchon/templates/parallel/MediatorClient.hpp> 175 #include <samchon/templates/parallel/MediatorWebClient.hpp> 176 #include <samchon/templates/parallel/MediatorServer.hpp> 177 #include <samchon/templates/parallel/MediatorWebServer.hpp>
auto has(const Key &key) const -> bool
Whether have the item or not.
auto get(const Key &key) -> T &
Get element.
Customized std::unordered_map.