Samchon Framework for CPP  1.0.0
ParallelSystem_slave.cpp
1 #include <samchon/protocol/slave/ParallelSystem.hpp>
2 
3 #include <samchon/protocol/Invoke.hpp>
4 #include <samchon/protocol/InvokeHistory.hpp>
5 #include <thread>
6 
7 using namespace std;
8 using namespace samchon::library;
9 using namespace samchon::protocol;
10 using namespace samchon::protocol::slave;
11 
12 ParallelSystem::ParallelSystem()
13  : super()
14 {
15 }
16 auto ParallelSystem::createChild(shared_ptr<XML>) -> ExternalSystemRole*
17 {
18  return nullptr;
19 }
20 
21 void ParallelSystem::_replyData(shared_ptr<Invoke> invoke)
22 {
23  if (invoke->has("invoke_history_uid") == true)
24  {
25  thread
26  (
27  [this, invoke]
28  {
29  InvokeHistory history(invoke);
30 
31  size_t index = invoke->get("invoke_history_index")->getValue<size_t>();
32  size_t size = invoke->get("invoke_history_size")->getValue<size_t>();
33 
34  replyPieceData(invoke, index, size);
35 
36  history.notifyEnd();
37  this->sendData(history.toInvoke());
38  }
39  ).detach();
40  }
41  else
42  replyData(invoke);
43 }
virtual auto createChild(std::shared_ptr< library::XML >) -> ExternalSystemRole *override
Factory method of a child Entity.
Package of external system, within the framework of slave.
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
A history of an Invoke message.
virtual void sendData(std::shared_ptr< Invoke >)
Sends message to a related system.
Definition: IClient.cpp:309
virtual void replyData(std::shared_ptr< Invoke >) override
Handling replied message from an external system.
An Entity and a container of children Entity objects.
Definition: EntityGroup.hpp:52
Package of network protocol and libraries.
Definition: protocol.hpp:185
virtual void replyPieceData(std::shared_ptr< Invoke >, size_t, size_t)=0
Handle requested processes which are segmented.
A role belongs to an external system.
virtual void notifyEnd()
Notify end of the process.
auto toInvoke() const -> std::shared_ptr< Invoke >
Get an Invoke message.
virtual void _replyData(std::shared_ptr< Invoke >) override
Pre-processor for segmented processes and reporting elapsed time.