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
@@ -1,40 +1,39 @@
|
||||
#include "QuickTest.h"
|
||||
#include "ICmd.h"
|
||||
|
||||
#include "lib/mercury/actors/PingPong.h"
|
||||
#include "lib/mercury/broker/AsyncEventBroker.h"
|
||||
#include "lib/mercury/mercury_utils/Executor.h"
|
||||
#include "lib/mercury/executor/Executor.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
int QuickTest::execute(std::vector<std::string> const &) {
|
||||
void test_ping_pong_mercury2()
|
||||
{
|
||||
using namespace mercury;
|
||||
|
||||
auto br1 = std::make_shared<AsyncEventBroker>();
|
||||
Executor executor1(*br1);
|
||||
auto br2 = std::make_shared<AsyncEventBroker>();
|
||||
Executor executor2(*br2);
|
||||
Executor ex1;
|
||||
Executor ex2;
|
||||
|
||||
auto v = std::vector<IEventBrokerPtr>{br1, br2};
|
||||
br1->init_neighbours(v);
|
||||
br2->init_neighbours(v);
|
||||
|
||||
executor1.spawn<Ping>();
|
||||
executor2.spawn<Pong>();
|
||||
ex1.init_neighbours(std::vector<Executor*> {&ex2});
|
||||
ex2.init_neighbours(std::vector<Executor*> {&ex1});
|
||||
|
||||
auto t = std::thread([&executor2]() {
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(1, &cpuset);
|
||||
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
ex1.spawn<Ping>();
|
||||
ex1.spawn<Pong>();
|
||||
//ex2.spawn<Pong>();
|
||||
|
||||
while (true)
|
||||
executor2.do_work();
|
||||
});
|
||||
// auto t = std::thread([&ex2]() {
|
||||
// cpu_set_t cpuset;
|
||||
// CPU_ZERO(&cpuset);
|
||||
// CPU_SET(1, &cpuset);
|
||||
// pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
|
||||
bts::sleep_for(2s);
|
||||
// while (true)
|
||||
// ex2.do_work();
|
||||
// });
|
||||
|
||||
// bts::sleep_for(2s);
|
||||
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
@@ -42,15 +41,20 @@ int QuickTest::execute(std::vector<std::string> const &) {
|
||||
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
|
||||
while (true) {
|
||||
executor1.do_work();
|
||||
ex1.do_work();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int QuickTest::execute(std::vector<std::string> const &) {
|
||||
test_ping_pong_mercury2();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string QuickTest::help() {
|
||||
return "This is a place holder to make it easy to quickly write discardable "
|
||||
"test code";
|
||||
"test code";
|
||||
}
|
||||
} // namespace cmd
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user