aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2018-08-01 13:30:43 -0400
committerDeterminant <tederminant@gmail.com>2018-08-01 13:30:43 -0400
commitbc078abd9d5fcc420dfbcda06869a95aba39b1ea (patch)
tree41ecd1a541abd7744d18f8c118f1984bafbe75b0 /test
parent8c965718031f0de6401aa30579da2e10afbcaf96 (diff)
use reference in place of pointers
Diffstat (limited to 'test')
-rw-r--r--test/bench_network.cpp6
-rw-r--r--test/test_network.cpp16
2 files changed, 11 insertions, 11 deletions
diff --git a/test/bench_network.cpp b/test/bench_network.cpp
index c2406d5..19f0dd9 100644
--- a/test/bench_network.cpp
+++ b/test/bench_network.cpp
@@ -109,8 +109,8 @@ struct MyNet: public MsgNetworkByteOp {
net->name.c_str());
/* send the first message through this connection */
net->ev_period_send = Event(net->ec, -1, 0,
- [net, this](int, short) {
- net->send_msg(MsgBytes(256), this);
+ [net, conn = self()](int, short) {
+ net->send_msg(MsgBytes(256), *conn);
net->ev_period_send.add_with_timeout(0);
});
net->ev_period_send.add_with_timeout(0);
@@ -133,7 +133,7 @@ struct MyNet: public MsgNetworkByteOp {
return new Conn();
}
- void on_receive_bytes(MsgBytes &&msg, const Conn *conn) {
+ void on_receive_bytes(MsgBytes &&msg, Conn &conn) {
nrecv++;
}
};
diff --git a/test/test_network.cpp b/test/test_network.cpp
index 49a13c2..fa08596 100644
--- a/test/test_network.cpp
+++ b/test/test_network.cpp
@@ -89,16 +89,16 @@ struct MyNet: public MsgNetworkByteOp {
reg_handler(salticidae::handler_bind(
&MyNet::on_receive_hello, this, _1, _2));
- reg_conn_handler([this](ConnPool::Conn *conn) {
- if (conn->get_fd() != -1)
+ reg_conn_handler([this](ConnPool::Conn &conn) {
+ if (conn.get_fd() != -1)
{
- if (conn->get_mode() == ConnPool::Conn::ACTIVE)
+ if (conn.get_mode() == ConnPool::Conn::ACTIVE)
{
printf("[%s] Connected, sending hello.\n",
this->name.c_str());
/* send the first message through this connection */
send_msg(MsgHello(this->name, "Hello there!"),
- static_cast<Conn *>(conn));
+ static_cast<Conn &>(conn));
}
else
printf("[%s] Accepted, waiting for greetings.\n",
@@ -108,7 +108,7 @@ struct MyNet: public MsgNetworkByteOp {
{
printf("[%s] Disconnected, retrying.\n", this->name.c_str());
/* try to reconnect to the same address */
- connect(conn->get_addr());
+ connect(conn.get_addr());
}
});
}
@@ -117,7 +117,7 @@ struct MyNet: public MsgNetworkByteOp {
return new Conn();
}
- void on_receive_hello(MsgHello &&msg, MyNet::Conn *conn) {
+ void on_receive_hello(MsgHello &&msg, MyNet::Conn &conn) {
printf("[%s] %s says %s\n",
name.c_str(),
msg.name.c_str(), msg.text.c_str());
@@ -127,8 +127,8 @@ struct MyNet: public MsgNetworkByteOp {
};
-void on_receive_ack(MsgAck &&msg, MyNet::Conn *conn) {
- auto net = static_cast<MyNet *>(conn->get_net());
+void on_receive_ack(MsgAck &&msg, MyNet::Conn &conn) {
+ auto net = static_cast<MyNet *>(conn.get_net());
printf("[%s] the peer knows\n", net->name.c_str());
}