From c194f922e46413e95a2c214c08c022677eb86d97 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 8 Dec 2021 10:59:00 -0700 Subject: [PATCH] Rename a few variables to make their intent clearer. --- include/deal.II/base/work_stream.h | 39 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/include/deal.II/base/work_stream.h b/include/deal.II/base/work_stream.h index 86b9626934..8ff38fe85a 100644 --- a/include/deal.II/base/work_stream.h +++ b/include/deal.II/base/work_stream.h @@ -238,23 +238,23 @@ namespace WorkStream /** * A list of iterators that need to be worked on. Only the first - * n_items are relevant. + * n_iterators are relevant. */ - std::vector work_items; + std::vector iterators; /** * The CopyData objects that the Worker part of the pipeline fills - * for each work item. Again, only the first n_items elements are + * for each work item. Again, only the first n_iterators elements are * what we care about. */ std::vector copy_datas; /** - * Number of items identified by the work_items array that the + * Number of items identified by the iterators array that the * Worker and Copier pipeline stage need to work on. The maximum * value of this variable will be chunk_size. */ - unsigned int n_items; + unsigned int n_iterators; /** * Pointer to a thread local variable identifying the scratch data @@ -307,7 +307,7 @@ namespace WorkStream * default constructor itself. */ ItemType() - : n_items(0) + : n_iterators(0) , scratch_data(nullptr) , sample_scratch_data(nullptr) , currently_in_use(false) @@ -334,10 +334,10 @@ namespace WorkStream // initialize the elements of the ring buffer for (auto &item : item_buffer) { - Assert(item.n_items == 0, ExcInternalError()); + Assert(item.n_iterators == 0, ExcInternalError()); - item.work_items.resize(chunk_size, - remaining_iterator_range.second); + item.iterators.resize(chunk_size, + remaining_iterator_range.second); item.scratch_data = &thread_local_scratch; item.sample_scratch_data = &sample_scratch_data; item.copy_datas.resize(chunk_size, sample_copy_data); @@ -380,19 +380,19 @@ namespace WorkStream // initialize the next item. it may // consist of at most chunk_size // elements - current_item->n_items = 0; + current_item->n_iterators = 0; while ((remaining_iterator_range.first != remaining_iterator_range.second) && - (current_item->n_items < chunk_size)) + (current_item->n_iterators < chunk_size)) { - current_item->work_items[current_item->n_items] = + current_item->iterators[current_item->n_iterators] = remaining_iterator_range.first; ++remaining_iterator_range.first; - ++current_item->n_items; + ++current_item->n_iterators; } - if (current_item->n_items == 0) + if (current_item->n_iterators == 0) // there were no items // left. terminate the pipeline return nullptr; @@ -525,7 +525,7 @@ namespace WorkStream // see if there is an unused object. if so, grab it and mark // it as used for (auto &p : current_item->scratch_data->get()) - if (p->currently_in_use == false) + if (p.currently_in_use == false) { scratch_data = p.scratch_data.get(); p.currently_in_use = true; @@ -538,7 +538,8 @@ namespace WorkStream { scratch_data = new ScratchData(*current_item->sample_scratch_data); - current_item->scratch_data->get().emplace_back(scratch_data, true); + current_item->scratch_data->get().emplace_back(scratch_data, + true); } } @@ -546,12 +547,12 @@ namespace WorkStream // were given. since these worker functions are called on separate // threads, nothing good can happen if they throw an exception and // we are best off catching it and showing an error message - for (unsigned int i = 0; i < current_item->n_items; ++i) + for (unsigned int i = 0; i < current_item->n_iterators; ++i) { try { if (worker) - worker(current_item->work_items[i], + worker(current_item->iterators[i], *scratch_data, current_item->copy_datas[i]); } @@ -596,7 +597,7 @@ namespace WorkStream // Initiate copying data. For the same reasons as in the worker // class above, catch exceptions rather than letting them // propagate into unknown territories: - for (unsigned int i = 0; i < current_item->n_items; ++i) + for (unsigned int i = 0; i < current_item->n_iterators; ++i) { try { -- 2.39.5