mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 08:56:26 +02:00
Use lock_guard when possible
This commit is contained in:
parent
a4d383b384
commit
eb8b37309d
1 changed files with 18 additions and 21 deletions
|
@ -191,12 +191,10 @@ void SendQueue::nak(SequenceNumber start, SequenceNumber end) {
|
||||||
_timeoutExpiryCount = 0;
|
_timeoutExpiryCount = 0;
|
||||||
_lastReceiverResponse = uint64_t(QDateTime::currentMSecsSinceEpoch());
|
_lastReceiverResponse = uint64_t(QDateTime::currentMSecsSinceEpoch());
|
||||||
|
|
||||||
std::unique_lock<std::mutex> nakLocker(_naksLock);
|
{
|
||||||
|
std::lock_guard<std::mutex> nakLocker(_naksLock);
|
||||||
_naks.insert(start, end);
|
_naks.insert(start, end);
|
||||||
|
}
|
||||||
// unlock the locked mutex before we notify
|
|
||||||
nakLocker.unlock();
|
|
||||||
|
|
||||||
// call notify_one on the condition_variable_any in case the send thread is sleeping waiting for losses to re-send
|
// call notify_one on the condition_variable_any in case the send thread is sleeping waiting for losses to re-send
|
||||||
_emptyCondition.notify_one();
|
_emptyCondition.notify_one();
|
||||||
|
@ -207,7 +205,8 @@ void SendQueue::overrideNAKListFromPacket(ControlPacket& packet) {
|
||||||
_timeoutExpiryCount = 0;
|
_timeoutExpiryCount = 0;
|
||||||
_lastReceiverResponse = uint64_t(QDateTime::currentMSecsSinceEpoch());
|
_lastReceiverResponse = uint64_t(QDateTime::currentMSecsSinceEpoch());
|
||||||
|
|
||||||
std::unique_lock<std::mutex> nakLocker(_naksLock);
|
{
|
||||||
|
std::lock_guard<std::mutex> nakLocker(_naksLock);
|
||||||
_naks.clear();
|
_naks.clear();
|
||||||
|
|
||||||
SequenceNumber first, second;
|
SequenceNumber first, second;
|
||||||
|
@ -221,9 +220,7 @@ void SendQueue::overrideNAKListFromPacket(ControlPacket& packet) {
|
||||||
_naks.append(first, second);
|
_naks.append(first, second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// unlock the mutex before we notify
|
|
||||||
nakLocker.unlock();
|
|
||||||
|
|
||||||
// call notify_one on the condition_variable_any in case the send thread is sleeping waiting for losses to re-send
|
// call notify_one on the condition_variable_any in case the send thread is sleeping waiting for losses to re-send
|
||||||
_emptyCondition.notify_one();
|
_emptyCondition.notify_one();
|
||||||
|
@ -247,7 +244,7 @@ void SendQueue::sendHandshake() {
|
||||||
|
|
||||||
void SendQueue::handshakeACK() {
|
void SendQueue::handshakeACK() {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> locker { _handshakeMutex };
|
std::lock_guard<std::mutex> locker { _handshakeMutex };
|
||||||
_hasReceivedHandshakeACK = true;
|
_hasReceivedHandshakeACK = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue