Replace concurrentqueue with ringbuffer

This commit is contained in:
Jonathan Schwartz
2024-04-05 17:24:53 +00:00
parent 7d2d12c5cd
commit 63f0516318
22 changed files with 361 additions and 169 deletions
+3 -5
View File
@@ -24,11 +24,9 @@ std::vector<uint8_t>& Packetizer::packetWrap(std::vector<uint8_t>& data, bool sh
return data;
}
bool Packetizer::input(const std::vector<uint8_t>& inputBytes) {
bool Packetizer::input(RingBuffer& bytes) {
bool haveEnoughData = true;
bytes.Copy(inputBytes);
while(haveEnoughData) {
switch(state) {
case ReadState::SearchForHeader:
@@ -152,14 +150,14 @@ bool Packetizer::input(const std::vector<uint8_t>& inputBytes) {
if(packetLength > 0)
packet.data.resize(packetLength - headerSize);
bytes.CopyTo(packet.data.data(), currentIndex, (packetLength - currentIndex));
bytes.read(packet.data.data(), currentIndex, (packetLength - currentIndex));
currentIndex = packetLength;
if(disableChecksum || !checksum || bytes[currentIndex] == ICSChecksum(packet.data)) {
// Got a good packet
gotGoodPackets = true;
processedPackets.push_back(std::make_shared<Packet>(packet));
bytes.Erase_front(packetLength);
bytes.pop(packetLength);
if(packet.network == Network::NetID::DiskData && (packetLength - headerSize) % 2 == 0) {
bytes.pop_front();