diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2021-12-01 20:22:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-01 20:22:33 +0100 |
commit | 57a59ae92d4bbfa4fdd60d7acd72c6440f63a49c (patch) | |
tree | 6efa0044d48f5e241540b412ef4c7fe63edec570 /src/network/connectionthreads.h | |
parent | 1dc1305ada07da8c2a278b46a34d58af86184af9 (diff) | |
download | minetest-57a59ae92d4bbfa4fdd60d7acd72c6440f63a49c.tar.gz minetest-57a59ae92d4bbfa4fdd60d7acd72c6440f63a49c.tar.bz2 minetest-57a59ae92d4bbfa4fdd60d7acd72c6440f63a49c.zip |
Network: Delete copy constructor and use std::move instead (#11642)
This is a follow-up change which disables class copies where possible to avoid unnecessary memory movements.
Diffstat (limited to 'src/network/connectionthreads.h')
-rw-r--r-- | src/network/connectionthreads.h | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/network/connectionthreads.h b/src/network/connectionthreads.h index 612407c3b..c2e2dae12 100644 --- a/src/network/connectionthreads.h +++ b/src/network/connectionthreads.h @@ -29,6 +29,25 @@ namespace con class Connection; +struct OutgoingPacket +{ + session_t peer_id; + u8 channelnum; + SharedBuffer<u8> data; + bool reliable; + bool ack; + + OutgoingPacket(session_t peer_id_, u8 channelnum_, const SharedBuffer<u8> &data_, + bool reliable_,bool ack_=false): + peer_id(peer_id_), + channelnum(channelnum_), + data(data_), + reliable(reliable_), + ack(ack_) + { + } +}; + class ConnectionSendThread : public Thread { @@ -51,27 +70,27 @@ public: private: void runTimeouts(float dtime); - void rawSend(const BufferedPacket &packet); + void rawSend(const BufferedPacket *p); bool rawSendAsPacket(session_t peer_id, u8 channelnum, const SharedBuffer<u8> &data, bool reliable); - void processReliableCommand(ConnectionCommand &c); - void processNonReliableCommand(ConnectionCommand &c); + void processReliableCommand(ConnectionCommandPtr &c); + void processNonReliableCommand(ConnectionCommandPtr &c); void serve(Address bind_address); void connect(Address address); void disconnect(); void disconnect_peer(session_t peer_id); void send(session_t peer_id, u8 channelnum, const SharedBuffer<u8> &data); - void sendReliable(ConnectionCommand &c); + void sendReliable(ConnectionCommandPtr &c); void sendToAll(u8 channelnum, const SharedBuffer<u8> &data); - void sendToAllReliable(ConnectionCommand &c); + void sendToAllReliable(ConnectionCommandPtr &c); void sendPackets(float dtime); void sendAsPacket(session_t peer_id, u8 channelnum, const SharedBuffer<u8> &data, bool ack = false); - void sendAsPacketReliable(BufferedPacket &p, Channel *channel); + void sendAsPacketReliable(BufferedPacketPtr &p, Channel *channel); bool packetsQueued(); |