Skip to content
Snippets Groups Projects
Commit 6e6b106b authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2
Browse files

socketpair: optimize lock/write with RTCP packets

This patch prevents SocketPair::getRtcpInfo() to lock a mutex
during a consequent memory copy and reduce copy cpu load by using
move iterators.

Change-Id: Ie729cb0677c45639f5a92ae842e93032c26f1a02
parent e916e448
No related branches found
No related tags found
No related merge requests found
......@@ -261,11 +261,14 @@ SocketPair::saveRtcpPacket(uint8_t* buf, size_t len)
std::vector<rtcpRRHeader>
SocketPair::getRtcpInfo()
{
std::lock_guard<std::mutex> lock(rtcpInfo_mutex_);
std::vector<rtcpRRHeader> vect(listRtcpHeader_.size());
std::copy_n(listRtcpHeader_.begin(), listRtcpHeader_.size(), vect.begin());
listRtcpHeader_.clear();
return vect;
decltype(listRtcpHeader_) l;
{
std::lock_guard<std::mutex> lock(rtcpInfo_mutex_);
if (listRtcpHeader_.empty())
return {};
l = std::move(listRtcpHeader_);
}
return {std::make_move_iterator(l.begin()), std::make_move_iterator(l.end())};
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment