mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
fix: address PR reviewer feedback regarding random_shuffle and queue.empty()
This commit is contained in:
parent
42b0352ec3
commit
c122bff122
|
|
@ -530,8 +530,7 @@ void Villager::addOffers(int addCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// shuffle the list to make it more interesting
|
// shuffle the list to make it more interesting
|
||||||
std::random_device rd;
|
static thread_local std::mt19937 g(std::random_device{}());
|
||||||
std::mt19937 g(rd());
|
|
||||||
std::shuffle(newOffers->begin(), newOffers->end(), g);
|
std::shuffle(newOffers->begin(), newOffers->end(), g);
|
||||||
|
|
||||||
if (offers == NULL)
|
if (offers == NULL)
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ void Socket::SocketInputStreamLocal::close()
|
||||||
{
|
{
|
||||||
m_streamOpen = false;
|
m_streamOpen = false;
|
||||||
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
||||||
while(!s_hostQueue[m_queueIdx].empty()) s_hostQueue[m_queueIdx].pop();
|
std::queue<uint8_t>().swap(s_hostQueue[m_queueIdx]);
|
||||||
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -392,7 +392,7 @@ void Socket::SocketOutputStreamLocal::close()
|
||||||
{
|
{
|
||||||
m_streamOpen = false;
|
m_streamOpen = false;
|
||||||
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
||||||
while(!s_hostQueue[m_queueIdx].empty()) s_hostQueue[m_queueIdx].pop();
|
std::queue<uint8_t>().swap(s_hostQueue[m_queueIdx]);
|
||||||
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue