diff --git a/async/as/MPIBase.h b/async/as/MPIBase.h index 0783f17..814e140 100644 --- a/async/as/MPIBase.h +++ b/async/as/MPIBase.h @@ -240,9 +240,8 @@ class MPIBase : public ThreadBase, private S * Reset the buffer position on non-executors */ void resetBufferPosition() { - for (typename std::vector::iterator it = m_buffer.begin(); it != m_buffer.end(); - it++) { - it->position = 0; + for (auto& buffer : m_buffer) { + buffer.position = 0; } } @@ -431,13 +430,11 @@ class MPIBase : public ThreadBase, private S } void _finalize() override { - for (typename std::vector::iterator it = m_executorBuffer.begin(); - it != m_executorBuffer.end(); - ++it) { - delete[] it->offsets; - it->offsets = 0L; - delete[] it->positions; - it->positions = 0L; + for (auto& execBuffer : m_executorBuffer) { + delete[] execBuffer.offsets; + execBuffer.offsets = 0L; + delete[] execBuffer.positions; + execBuffer.positions = 0L; } ThreadBase::finalize(); @@ -456,11 +453,9 @@ class MPIBase : public ThreadBase, private S * Should only be called on the executor. */ void resetBufferPositionOnExecutor() { - for (typename std::vector::iterator it = m_executorBuffer.begin(); - it != m_executorBuffer.end(); - it++) { - if (it->positions) { - memset(it->positions, 0, (m_scheduler->groupSize() - 1) * sizeof(size_t)); + for (auto& execBuffer : m_executorBuffer) { + if (execBuffer.positions) { + memset(execBuffer.positions, 0, (m_scheduler->groupSize() - 1) * sizeof(size_t)); } } } diff --git a/async/as/MPIScheduler.h b/async/as/MPIScheduler.h index f479d44..4a85e90 100644 --- a/async/as/MPIScheduler.h +++ b/async/as/MPIScheduler.h @@ -270,12 +270,10 @@ class MPIScheduler { MPI_Mrecv(0L, 0, MPI_CHAR, &message, MPI_STATUS_IGNORE); // Stop everything immediately (probably some finalizes were missing) - for (std::vector::iterator it = m_asyncCalls.begin(); - it != m_asyncCalls.end(); - ++it) { - if (*it) { - (*it)->_finalize(); - *it = 0; + for (auto& call : m_asyncCalls) { + if (call) { + call->_finalize(); + call = 0; } } goto kill; diff --git a/async/as/Thread.h b/async/as/Thread.h index 29909ca..ec21403 100644 --- a/async/as/Thread.h +++ b/async/as/Thread.h @@ -189,8 +189,9 @@ class Thread : public ThreadBase { private: void resetBufferPosition() { - for (typename std::vector::iterator it = m_buffer.begin(); it != m_buffer.end(); ++it) - it->position = 0; + for (auto& buffer : m_buffer) { + buffer.position = 0; + } } }; diff --git a/async/as/ThreadBase.h b/async/as/ThreadBase.h index 0aab25e..1a6f2ae 100644 --- a/async/as/ThreadBase.h +++ b/async/as/ThreadBase.h @@ -209,7 +209,7 @@ class ThreadBase : public Base { void wait() override { // wait for the previous call to finish lock_spinlock(&m_writerLock); - + // signal wait m_waiting = true; pthread_mutex_unlock(&m_readerLock);