Codechange: use std::deque of std::unique_ptr to queue packets

This commit is contained in:
Rubidium
2024-02-03 19:35:36 +01:00
committed by rubidium42
parent c77a45ed86
commit 36e1b32ccf
5 changed files with 32 additions and 99 deletions

View File

@@ -30,7 +30,7 @@ enum SendPacketsState {
/** Base socket handler for all TCP sockets */
class NetworkTCPSocketHandler : public NetworkSocketHandler {
private:
Packet *packet_queue; ///< Packets that are awaiting delivery
std::deque<std::unique_ptr<Packet>> packet_queue; ///< Packets that are awaiting delivery. Cannot be std::queue as that does not have a clear() function.
std::unique_ptr<Packet> packet_recv; ///< Partially received packet
void EmptyPacketQueue();
@@ -58,7 +58,7 @@ public:
* Whether there is something pending in the send queue.
* @return true when something is pending in the send queue.
*/
bool HasSendQueue() { return this->packet_queue != nullptr; }
bool HasSendQueue() { return !this->packet_queue.empty(); }
NetworkTCPSocketHandler(SOCKET s = INVALID_SOCKET);
~NetworkTCPSocketHandler();