Change clientpackets to std::deque from LinkedList

This should be better performance, but I couldn't really
push local testing to hit the performance issues ...
This commit is contained in:
Michael Cook (mackal) 2017-04-25 02:13:31 -04:00
parent 757c7f5b00
commit 34549a4bdb
2 changed files with 10 additions and 11 deletions

View File

@ -697,12 +697,13 @@ bool Client::AddPacket(const EQApplicationPacket *pApp, bool bAckreq) {
//drop the packet because it will never get sent.
return(false);
}
auto c = new CLIENTPACKET;
auto c = std::unique_ptr<CLIENTPACKET>(new CLIENTPACKET);
c->ack_req = bAckreq;
c->app = pApp->Copy();
clientpackets.Append(c);
clientpackets.push_back(std::move(c));
return true;
}
@ -714,26 +715,23 @@ bool Client::AddPacket(EQApplicationPacket** pApp, bool bAckreq) {
//drop the packet because it will never get sent.
return(false);
}
auto c = new CLIENTPACKET;
auto c = std::unique_ptr<CLIENTPACKET>(new CLIENTPACKET);
c->ack_req = bAckreq;
c->app = *pApp;
*pApp = nullptr;
clientpackets.Append(c);
clientpackets.push_back(std::move(c));
return true;
}
bool Client::SendAllPackets() {
LinkedListIterator<CLIENTPACKET*> iterator(clientpackets);
CLIENTPACKET* cp = nullptr;
iterator.Reset();
while(iterator.MoreElements()) {
cp = iterator.GetData();
while (!clientpackets.empty()) {
cp = clientpackets.front().get();
if(eqs)
eqs->FastQueuePacket((EQApplicationPacket **)&cp->app, cp->ack_req);
iterator.RemoveCurrent();
clientpackets.pop_front();
Log(Logs::Moderate, Logs::Client_Server_Packet, "Transmitting a packet");
}
return true;

View File

@ -70,6 +70,7 @@ namespace EQEmu
#include <set>
#include <algorithm>
#include <memory>
#include <deque>
#define CLIENT_TIMEOUT 90000
@ -1424,7 +1425,7 @@ private:
bool AddPacket(const EQApplicationPacket *, bool);
bool AddPacket(EQApplicationPacket**, bool);
bool SendAllPackets();
LinkedList<CLIENTPACKET *> clientpackets;
std::deque<std::unique_ptr<CLIENTPACKET>> clientpackets;
//Zoning related stuff
void SendZoneCancel(ZoneChange_Struct *zc);