]> git.sesse.net Git - plocate/commitdiff
Use unique_lock CTAD.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 15 Oct 2022 13:44:47 +0000 (15:44 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 15 Oct 2022 13:44:47 +0000 (15:44 +0200)
It's not useful to write unique_lock<mutex> in C++17;
unique_lock will do.

plocate.cpp

index a1cd97a4a4645c08880b014d4799f9d4c33182f6..28a9c28bfe52065b8425fffdb4ffef661b501865 100644 (file)
@@ -367,7 +367,7 @@ uint64_t scan_all_docids(const vector<Needle> &needles, int fd, const Corpus &co
                                string compressed;
 
                                {
-                                       unique_lock<mutex> lock(mu);
+                                       unique_lock lock(mu);
                                        queue_added.wait(lock, [&work_queue, &done] { return !work_queue.empty() || done; });
                                        if (done && work_queue.empty()) {
                                                return;
@@ -397,7 +397,7 @@ uint64_t scan_all_docids(const vector<Needle> &needles, int fd, const Corpus &co
                complete_pread(fd, &compressed[0], io_len, offsets[io_docid]);
 
                {
-                       unique_lock<mutex> lock(mu);
+                       unique_lock lock(mu);
                        queue_removed.wait(lock, [&work_queue] { return work_queue.size() < 256; });  // Allow ~2MB of data queued up.
                        work_queue.emplace_back(io_docid, last_docid, move(compressed));
                        queue_added.notify_one();  // Avoid the thundering herd.