mirror of https://github.com/AxioDL/jbus.git
Merge pull request #7 from lioncash/assignment
Listener: Simplify assignment within accept()
This commit is contained in:
commit
fb3d880b63
|
@ -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,15 +94,15 @@ 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());
|
||||
std::unique_lock lk{m_queueLock};
|
||||
if (m_endpointQueue.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto ret = std::move(m_endpointQueue.front());
|
||||
m_endpointQueue.pop();
|
||||
return ret;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Listener::Listener() = default;
|
||||
|
||||
|
|
Loading…
Reference in New Issue