use a mutable mutex to keep const-ness

This commit is contained in:
Stephen Birarda 2015-09-30 14:23:18 -04:00
parent f7e7b07441
commit 82ac0b1a27
3 changed files with 5 additions and 4 deletions

View file

@ -39,7 +39,7 @@ void SentPacketHistory::packetSent(uint16_t sequenceNumber, const NLPacket& pack
_sentPackets.insert(NLPacket::createCopy(packet));
}
const NLPacket* SentPacketHistory::getPacket(uint16_t sequenceNumber) {
const NLPacket* SentPacketHistory::getPacket(uint16_t sequenceNumber) const {
const int UINT16_RANGE = std::numeric_limits<uint16_t>::max() + 1;

View file

@ -28,10 +28,10 @@ public:
SentPacketHistory(int size = MAX_REASONABLE_SEQUENCE_GAP);
void packetSent(uint16_t sequenceNumber, const NLPacket& packet);
const NLPacket* getPacket(uint16_t sequenceNumber);
const NLPacket* getPacket(uint16_t sequenceNumber) const;
private:
QReadWriteLock _packetsLock { QReadWriteLock::Recursive };
mutable QReadWriteLock _packetsLock { QReadWriteLock::Recursive };
RingBufferHistory<std::unique_ptr<NLPacket>> _sentPackets; // circular buffer
uint16_t _newestSequenceNumber;

View file

@ -346,7 +346,8 @@ void OctreeEditPacketSender::processNackPacket(NLPacket& packet, SharedNodePoint
if (_sentPacketHistories.count(sendingNode->getUUID()) == 0) {
return;
}
SentPacketHistory& sentPacketHistory = _sentPacketHistories[sendingNode->getUUID()];
const SentPacketHistory& sentPacketHistory = _sentPacketHistories[sendingNode->getUUID()];
// read sequence numbers and queue packets for resend
while (packet.bytesLeftToRead() > 0) {