Eliminate unnecessary global locks

Former-commit-id: 8f924ed0979f3cf7cd290395d1b1eec358979325
This commit is contained in:
John Sully 2021-05-31 01:14:28 +00:00
parent a2010f17b8
commit ac49c7158c

View File

@ -18,9 +18,9 @@ void AsyncWorkQueue::WorkerThreadMain()
vars.clients_pending_asyncwrite = listCreate();
aeAcquireLock();
m_mutex.lock();
m_vecpthreadVars.push_back(&vars);
aeReleaseLock();
m_mutex.unlock();
while (!m_fQuitting)
{
@ -42,9 +42,11 @@ void AsyncWorkQueue::WorkerThreadMain()
lock.unlock();
serverTL->gcEpoch = g_pserver->garbageCollector.startEpoch();
aeAcquireLock();
ProcessPendingAsyncWrites();
aeReleaseLock();
if (listLength(serverTL->clients_pending_asyncwrite)) {
aeAcquireLock();
ProcessPendingAsyncWrites();
aeReleaseLock();
}
g_pserver->garbageCollector.endEpoch(serverTL->gcEpoch);
serverTL->gcEpoch.reset();
}
@ -61,6 +63,7 @@ bool AsyncWorkQueue::removeClientAsyncWrites(client *c)
{
bool fFound = false;
aeAcquireLock();
m_mutex.lock();
for (auto pvars : m_vecpthreadVars)
{
listIter li;
@ -75,6 +78,7 @@ bool AsyncWorkQueue::removeClientAsyncWrites(client *c)
}
}
}
m_mutex.unlock();
aeReleaseLock();
return fFound;
}