Merge pull request #7 from lioncash/assignment

Listener: Simplify assignment within accept()
This commit is contained in:
Phillip Stephens 2019-09-03 19:54:45 -07:00 committed by GitHub
commit fb3d880b63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -68,7 +68,7 @@ void Listener::listenerProc() {
#endif
}
if (acceptData && acceptClock) {
std::unique_lock<std::mutex> lk(m_queueLock);
std::unique_lock lk{m_queueLock};
m_endpointQueue.push(std::make_unique<Endpoint>(0, std::move(acceptData), std::move(acceptClock)));
}
WaitGCTicks(GetGCTicksPerSec());
@ -94,14 +94,14 @@ void Listener::stop() {
}
std::unique_ptr<Endpoint> Listener::accept() {
std::unique_lock<std::mutex> lk(m_queueLock);
if (m_endpointQueue.size()) {
std::unique_ptr<Endpoint> ret;
ret = std::move(m_endpointQueue.front());
m_endpointQueue.pop();
return ret;
std::unique_lock lk{m_queueLock};
if (m_endpointQueue.empty()) {
return nullptr;
}
return {};
auto ret = std::move(m_endpointQueue.front());
m_endpointQueue.pop();
return ret;
}
Listener::Listener() = default;