aboutsummaryrefslogtreecommitdiff
path: root/test/bench_network_tls.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/bench_network_tls.cpp')
-rw-r--r--test/bench_network_tls.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/test/bench_network_tls.cpp b/test/bench_network_tls.cpp
index 2827a99..b5280b4 100644
--- a/test/bench_network_tls.cpp
+++ b/test/bench_network_tls.cpp
@@ -103,7 +103,7 @@ struct MyNet: public MsgNetworkByteOp {
{
if (conn->get_mode() == MyNet::Conn::ACTIVE)
{
- printf("[%s] Connected, sending hello.\n", this->name.c_str());
+ printf("[%s] connected, sending bytes.\n", this->name.c_str());
/* send the first message through this connection */
trigger = [this, conn](ThreadCall::Handle &) {
send_msg(MsgBytes(256), salticidae::static_pointer_cast<Conn>(conn));
@@ -113,11 +113,11 @@ struct MyNet: public MsgNetworkByteOp {
tcall.async_call(trigger);
}
else
- printf("[%s] Passively connected, waiting for greetings.\n", this->name.c_str());
+ printf("[%s] passively connected, waiting for bytes.\n", this->name.c_str());
}
else
{
- printf("[%s] Disconnected, retrying.\n", this->name.c_str());
+ printf("[%s] disconnected, retrying.\n", this->name.c_str());
/* try to reconnect to the same address */
connect(conn->get_addr(), false);
}
@@ -125,9 +125,7 @@ struct MyNet: public MsgNetworkByteOp {
});
}
- void on_receive_bytes(MsgBytes &&msg, const conn_t &conn) {
- nrecv++;
- }
+ void on_receive_bytes(MsgBytes &&msg, const conn_t &conn) { nrecv++; }
};
salticidae::EventContext ec;
@@ -139,20 +137,16 @@ int main() {
alice->start();
alice->listen(alice_addr);
salticidae::EventContext tec;
- salticidae::BoxObj<ThreadCall> tcall = new ThreadCall(tec);
- std::thread bob_thread([&tec]() {
- MyNet bob(tec, "Bob");
+ MyNet bob(tec, "Bob");
+ std::thread bob_thread([&]() {
bob.start();
bob.connect(alice_addr);
- try {
- tec.dispatch();
- } catch (std::exception &) {}
+ tec.dispatch();
});
auto shutdown = [&](int) {
- tcall->async_call([&](salticidae::ThreadCall::Handle &) {
+ bob.tcall.async_call([&](salticidae::ThreadCall::Handle &) {
tec.stop();
});
- alice = nullptr;
ec.stop();
bob_thread.join();
};