As we know, std::unique_lock might release the mutex when it's destructor called.
Consider the behavior of the line 8th in the source below, lck.unlock()
, my question is whether unlocking mutex before function return increase the concurrency or not?
MessageWrapper ServerLeftCommunicator::receive() {
unique_lock<mutex> lck(recvMsgQCvMtx_);
recvMsgQCv_.wait(lck, [this] {
return ! recvMsgQ_.empty();
});
auto wrapper = recvMsgQ_.front();
recvMsgQ_.pop();
lck.unlock();
return wrapper;
}
Thank you.