2016-02-02 15:40:07 +03:00
|
|
|
#ifndef MULTIVERSO_COMMUNICATION_H_
|
|
|
|
#define MULTIVERSO_COMMUNICATION_H_
|
|
|
|
|
2016-02-04 06:03:53 +03:00
|
|
|
#include "multiverso/actor.h"
|
|
|
|
#include "multiverso/message.h"
|
2016-02-02 15:40:07 +03:00
|
|
|
|
|
|
|
namespace multiverso {
|
|
|
|
|
|
|
|
class NetInterface;
|
|
|
|
|
|
|
|
class Communicator : public Actor {
|
|
|
|
public:
|
|
|
|
Communicator();
|
2016-03-04 10:54:07 +03:00
|
|
|
~Communicator();
|
|
|
|
|
2016-02-02 15:40:07 +03:00
|
|
|
private:
|
|
|
|
void Main() override;
|
|
|
|
// Process message received from other actors, either send to other nodes, or
|
|
|
|
// forward to local actors.
|
|
|
|
void ProcessMessage(MessagePtr& msg);
|
|
|
|
// Thread function to receive messages from other nodes
|
|
|
|
void Communicate();
|
|
|
|
// Forward to other actors in the same node
|
|
|
|
void LocalForward(MessagePtr& msg);
|
2016-08-10 06:22:15 +03:00
|
|
|
|
2016-02-02 15:40:07 +03:00
|
|
|
NetInterface* net_util_;
|
|
|
|
std::unique_ptr<std::thread> recv_thread_;
|
|
|
|
};
|
|
|
|
|
2016-04-08 11:57:29 +03:00
|
|
|
} // namespace multiverso
|
|
|
|
|
|
|
|
#endif // MULTIVERSO_COMMUNICATION_H_
|