Skip to content
Snippets Groups Projects
Commit 4d98e0f5 authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

ice: use lock_guard than unique_lock

The former has less overhead than later if extra features not needed.

Refs #73286

Change-Id: I2eb988dc546e92c934304a2e9b9419f5a025f23b
parent b1d2a0de
No related branches found
No related tags found
No related merge requests found
...@@ -560,7 +560,7 @@ IceTransport::onReceiveData(unsigned comp_id, void *pkt, pj_size_t size) ...@@ -560,7 +560,7 @@ IceTransport::onReceiveData(unsigned comp_id, void *pkt, pj_size_t size)
if (!size) if (!size)
return; return;
auto& io = compIO_[comp_id-1]; auto& io = compIO_[comp_id-1];
std::unique_lock<std::mutex> lk(io.mutex); std::lock_guard<std::mutex> lk(io.mutex);
if (io.cb) { if (io.cb) {
io.cb((uint8_t*)pkt, size); io.cb((uint8_t*)pkt, size);
} else { } else {
...@@ -629,7 +629,7 @@ IceTransport::recv(int comp_id, unsigned char* buf, size_t len) ...@@ -629,7 +629,7 @@ IceTransport::recv(int comp_id, unsigned char* buf, size_t len)
{ {
register_thread(); register_thread();
auto& io = compIO_[comp_id]; auto& io = compIO_[comp_id];
std::unique_lock<std::mutex> lk(io.mutex); std::lock_guard<std::mutex> lk(io.mutex);
if (io.queue.empty()) if (io.queue.empty())
return 0; return 0;
...@@ -646,7 +646,7 @@ void ...@@ -646,7 +646,7 @@ void
IceTransport::setOnRecv(unsigned comp_id, IceRecvCb cb) IceTransport::setOnRecv(unsigned comp_id, IceRecvCb cb)
{ {
auto& io = compIO_[comp_id]; auto& io = compIO_[comp_id];
std::unique_lock<std::mutex> lk(io.mutex); std::lock_guard<std::mutex> lk(io.mutex);
io.cb = cb; io.cb = cb;
if (cb) { if (cb) {
...@@ -684,7 +684,7 @@ ssize_t ...@@ -684,7 +684,7 @@ ssize_t
IceTransport::getNextPacketSize(int comp_id) IceTransport::getNextPacketSize(int comp_id)
{ {
auto& io = compIO_[comp_id]; auto& io = compIO_[comp_id];
std::unique_lock<std::mutex> lk(io.mutex); std::lock_guard<std::mutex> lk(io.mutex);
if (io.queue.empty()) { if (io.queue.empty()) {
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment