aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2018-11-19 22:19:56 -0500
committerDeterminant <[email protected]>2018-11-19 22:19:56 -0500
commit60c4af2602e18933f2b795500f44c6613c852f45 (patch)
tree4e4572be2e307e885f257cfeec23db16a7e6ec39 /include
parent86a583982c0ea8bd62be42c1c137fac1c82b706f (diff)
correctly use std::forward
Diffstat (limited to 'include')
-rw-r--r--include/salticidae/event.h2
-rw-r--r--include/salticidae/network.h14
2 files changed, 8 insertions, 8 deletions
diff --git a/include/salticidae/event.h b/include/salticidae/event.h
index 4a1a410..ca48e69 100644
--- a/include/salticidae/event.h
+++ b/include/salticidae/event.h
@@ -335,7 +335,7 @@ class ThreadCall {
notifier->notify(std::move(result));
}
template<typename T>
- void set_result(T data) {
+ void set_result(T &&data) {
result = Result(new T(std::forward<T>(data)),
[](void *ptr) {delete static_cast<T *>(ptr);});
}
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index c74ba7d..f2b99b3 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -192,7 +192,7 @@ class MsgNetwork: public ConnPool {
}
template<typename MsgType>
- void send_msg(const MsgType &msg, const conn_t &conn);
+ void send_msg(MsgType &&msg, const conn_t &conn);
using ConnPool::listen;
#ifdef SALTICIDAE_MSG_STAT
msg_stat_by_opcode_t &get_sent_by_opcode() const {
@@ -243,7 +243,7 @@ class ClientNetwork: public MsgNetwork<OpcodeType> {
MsgNet(ec, config) {}
template<typename MsgType>
- void send_msg(MsgType msg, const NetAddr &addr);
+ void send_msg(MsgType &&msg, const NetAddr &addr);
};
class PeerNetworkError: public ConnPoolError {
@@ -429,7 +429,7 @@ class PeerNetwork: public MsgNetwork<OpcodeType> {
const conn_t get_peer_conn(const NetAddr &paddr) const;
using MsgNet::send_msg;
template<typename MsgType>
- void send_msg(MsgType msg, const NetAddr &paddr);
+ void send_msg(MsgType &&msg, const NetAddr &paddr);
void listen(NetAddr listen_addr);
bool has_peer(const NetAddr &paddr) const;
conn_t connect(const NetAddr &addr) = delete;
@@ -472,8 +472,8 @@ void MsgNetwork<OpcodeType>::Conn::on_read() {
template<typename OpcodeType>
template<typename MsgType>
-void MsgNetwork<OpcodeType>::send_msg(const MsgType &_msg, const conn_t &conn) {
- Msg msg(_msg);
+void MsgNetwork<OpcodeType>::send_msg(MsgType &&_msg, const conn_t &conn) {
+ Msg msg(std::forward<MsgType>(_msg));
bytearray_t msg_data = msg.serialize();
SALTICIDAE_LOG_DEBUG("wrote message %s to %s",
std::string(msg).c_str(),
@@ -708,7 +708,7 @@ bool PeerNetwork<O, _, __>::has_peer(const NetAddr &paddr) const {
template<typename O, O _, O __>
template<typename MsgType>
-void PeerNetwork<O, _, __>::send_msg(MsgType msg, const NetAddr &paddr) {
+void PeerNetwork<O, _, __>::send_msg(MsgType &&msg, const NetAddr &paddr) {
this->disp_tcall->async_call(
[this, msg=std::forward<MsgType>(msg), paddr](ThreadCall::Handle &h) {
auto it = id2peer.find(paddr);
@@ -740,7 +740,7 @@ void ClientNetwork<OpcodeType>::Conn::on_teardown() {
template<typename OpcodeType>
template<typename MsgType>
-void ClientNetwork<OpcodeType>::send_msg(MsgType msg, const NetAddr &addr) {
+void ClientNetwork<OpcodeType>::send_msg(MsgType &&msg, const NetAddr &addr) {
this->disp_tcall->async_call(
[this, addr, msg=std::forward<MsgType>(msg)](ThreadCall::Handle &h) {
auto it = addr2conn.find(addr);