From: Steinar H. Gunderson Date: Thu, 15 Oct 2020 21:40:42 +0000 (+0200) Subject: Give the WorkerThread results a proper struct instead of std::tuple. X-Git-Tag: 1.0.4~7 X-Git-Url: https://git.sesse.net/?p=plocate;a=commitdiff_plain;h=edc3f0417302d72e5fbdc43e665db160fce30db5 Give the WorkerThread results a proper struct instead of std::tuple. --- diff --git a/plocate.cpp b/plocate.cpp index e313458..e8fbff3 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -417,7 +417,12 @@ struct WorkerThread { // since a lock on it becomes a huge choke point if there are // lots of threads. mutex result_mu; - vector> results; + struct Result { + uint64_t seq; + uint64_t skip; + string msg; + }; + vector results; }; class WorkerThreadReceiver : public ResultReceiver { @@ -427,7 +432,7 @@ public: void print(uint64_t seq, uint64_t skip, const string msg) override { lock_guard lock(wt->result_mu); - wt->results.emplace_back(seq, skip, move(msg)); + wt->results.emplace_back(WorkerThread::Result{ seq, skip, move(msg) }); } private: @@ -436,13 +441,13 @@ private: void deliver_results(WorkerThread *wt, Serializer *serializer) { - vector> results; + vector results; { lock_guard lock(wt->result_mu); results = move(wt->results); } - for (const auto &result : results) { - serializer->print(get<0>(result), get<1>(result), move(get<2>(result))); + for (const WorkerThread::Result &result : results) { + serializer->print(result.seq, result.skip, move(result.msg)); } }