Rewrite of mercury for better performance.
This commit is contained in:
1 parent
3005dfdc0f
commit
fa2a2e2107
60 files changed
+971
-1255
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#include "lib/mercury/executor/Executor.h"
|
||||
#include "lib/mercury/broker/Broker.h"
|
||||
#include "lib/mercury/broker/BrokerProxy.h"
|
||||
#include "lib/mercury/actors/Actor.h"
|
||||
#include "lib/mercury/actors/IPollableActor.h"
|
||||
|
||||
namespace bts {
|
||||
namespace mercury {
|
||||
|
||||
Executor::Executor() : _broker(), _actor_broker(_broker),_actors() {}
|
||||
|
||||
Executor::~Executor() {
|
||||
for (auto &a : _actors)
|
||||
a->deactivate();
|
||||
}
|
||||
|
||||
void Executor::init_neighbours(std::vector<Executor*> const&neighbours)
|
||||
{
|
||||
std::vector<IRemoteBroker*> broker_neighbours;
|
||||
for (auto e : neighbours)
|
||||
if (e != this)
|
||||
broker_neighbours.push_back(&e->make_proxy());
|
||||
for (auto n : broker_neighbours)
|
||||
_broker.add_neighbour(*n);
|
||||
}
|
||||
|
||||
|
||||
void Executor::activate(Actor *actor)
|
||||
{
|
||||
_actors.push_back(std::unique_ptr<Actor> (actor));
|
||||
auto pollable = dynamic_cast<IPollableActor*> (actor);
|
||||
if (pollable)
|
||||
_pollable_actors.push_back(pollable);
|
||||
actor->activate(_actor_broker);}
|
||||
|
||||
|
||||
BrokerProxy& Executor::make_proxy()
|
||||
{
|
||||
_neighbour_proxies.push_back(std::make_unique<BrokerProxy>(_broker));
|
||||
return *_neighbour_proxies.back();
|
||||
}
|
||||
|
||||
} // namespace mercury
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user