Skip to content

Commit d513065

Browse files
committed
use lock_guard instead of unique_lock where possible
1 parent b66ef80 commit d513065

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

examples/filteredCount.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct MyCounter {
6868
}
6969
}
7070
//now flush everything to shared state
71-
std::unique_lock<std::mutex> lck(state->lock);
71+
std::lock_guard<std::mutex> lck(state->lock);
7272
state->nodeCount += nodeCount;
7373
state->wayCount += wayCount;
7474
state->relationCount += relationCount;

osmpbf/blobfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ bool BlobFileIn::skipBlob()
402402
uint32_t blobLength;
403403
BlobDataType blobDataType;
404404

405-
std::unique_lock<std::mutex> lck(m_fileLock);
405+
std::lock_guard<std::mutex> lck(m_fileLock);
406406
readBlobHeader(blobLength, blobDataType);
407407
if (blobLength)
408408
{

osmpbf/pbistream.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ MultiFilePbiStream::hasNext() const {
131131

132132
bool
133133
MultiFilePbiStream::getNext(BlobDataBuffer & buffer) {
134-
std::unique_lock<std::mutex> lck(m_lock);
134+
std::lock_guard<std::mutex> lck(m_lock);
135135
if (!hasNext()) {
136136
return false;
137137
}
@@ -148,7 +148,7 @@ MultiFilePbiStream::getNext(BlobDataBuffer & buffer) {
148148

149149
bool
150150
MultiFilePbiStream::getNext(osmpbf::BlobDataMultiBuffer & buffers, int num) {
151-
std::unique_lock<std::mutex> lck(m_lock);
151+
std::lock_guard<std::mutex> lck(m_lock);
152152
osmpbf::BlobDataMultiBuffer tmpBuffer;
153153
if (num < 0) {
154154
num = std::numeric_limits<int>::max();
@@ -180,7 +180,7 @@ MultiFilePbiStream::getNext(osmpbf::BlobDataMultiBuffer & buffers, int num) {
180180

181181
bool
182182
MultiFilePbiStream::parseNext(PrimitiveBlockInputAdaptor& adaptor) {
183-
std::unique_lock<std::mutex> lck(m_lock);
183+
std::lock_guard<std::mutex> lck(m_lock);
184184
if (!hasNext()) {
185185
return false;
186186
}

0 commit comments

Comments
 (0)