Skip to content

Commit ec529b9

Browse files
committed
User ptr instead of non-const refs for parameters
1 parent ee5fc06 commit ec529b9

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/osmdata.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,14 @@ class multithreaded_processor
239239

240240
private:
241241
/// Get the next id from the queue.
242-
static osmid_t pop_id(idlist_t &queue, std::mutex &mutex)
242+
static osmid_t pop_id(idlist_t *queue, std::mutex *mutex)
243243
{
244244
osmid_t id = 0;
245245

246-
std::lock_guard<std::mutex> const lock{mutex};
247-
if (!queue.empty()) {
248-
id = queue.back();
249-
queue.pop_back();
246+
std::lock_guard<std::mutex> const lock{*mutex};
247+
if (!queue->empty()) {
248+
id = queue->back();
249+
queue->pop_back();
250250
}
251251

252252
return id;
@@ -256,8 +256,8 @@ class multithreaded_processor
256256
* Runs in the worker threads: As long as there are any, get ids from
257257
* the queue and let the outputs process the ways.
258258
*/
259-
static void do_ways(output_vec_t const &outputs, idlist_t &queue,
260-
std::mutex &mutex)
259+
static void do_ways(output_vec_t const &outputs, idlist_t *queue,
260+
std::mutex *mutex)
261261
{
262262
while (osmid_t const id = pop_id(queue, mutex)) {
263263
for (auto const &output : outputs) {
@@ -272,8 +272,8 @@ class multithreaded_processor
272272
* Runs in the worker threads: As long as there are any, get ids from
273273
* the queue and let the outputs process the relations.
274274
*/
275-
static void do_rels(output_vec_t const &outputs, idlist_t &queue,
276-
std::mutex &mutex)
275+
static void do_rels(output_vec_t const &outputs, idlist_t *queue,
276+
std::mutex *mutex)
277277
{
278278
while (osmid_t const id = pop_id(queue, mutex)) {
279279
for (auto const &output : outputs) {
@@ -285,13 +285,13 @@ class multithreaded_processor
285285
}
286286

287287
/// Runs in a worker thread: Update progress display once per second.
288-
static void print_stats(idlist_t &queue, std::mutex &mutex)
288+
static void print_stats(idlist_t *queue, std::mutex *mutex)
289289
{
290290
size_t queue_size;
291291
do {
292-
mutex.lock();
293-
queue_size = queue.size();
294-
mutex.unlock();
292+
mutex->lock();
293+
queue_size = queue->size();
294+
mutex->unlock();
295295

296296
fmt::print(stderr, "\rLeft to process: {}...", queue_size);
297297

@@ -314,10 +314,10 @@ class multithreaded_processor
314314
for (auto const &clone : m_clones) {
315315
workers.push_back(std::async(
316316
std::launch::async, std::forward<FUNCTION>(function),
317-
std::cref(clone), std::ref(m_queue), std::ref(m_mutex)));
317+
std::cref(clone), &m_queue, &m_mutex));
318318
}
319319
workers.push_back(std::async(std::launch::async, print_stats,
320-
std::ref(m_queue), std::ref(m_mutex)));
320+
&m_queue, &m_mutex));
321321

322322
for (auto &worker : workers) {
323323
try {

0 commit comments

Comments
 (0)