Skip to content

Commit

Permalink
Replace C++11-style iterators by C++14-style iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
davschneller committed May 28, 2024
1 parent 4c692f0 commit 4941d7d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
25 changes: 10 additions & 15 deletions async/as/MPIBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ class MPIBase : public ThreadBase<Executor, InitParameter, Parameter>, private S
* Reset the buffer position on non-executors
*/
void resetBufferPosition() {
for (typename std::vector<BufInfo>::iterator it = m_buffer.begin(); it != m_buffer.end();
it++) {
it->position = 0;
for (auto& buffer : m_buffer) {
buffer.position = 0;
}
}

Expand Down Expand Up @@ -431,13 +430,11 @@ class MPIBase : public ThreadBase<Executor, InitParameter, Parameter>, private S
}

void _finalize() override {
for (typename std::vector<ExecutorBufInfo>::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<Executor, InitParameter, Parameter>::finalize();
Expand All @@ -456,11 +453,9 @@ class MPIBase : public ThreadBase<Executor, InitParameter, Parameter>, private S
* Should only be called on the executor.
*/
void resetBufferPositionOnExecutor() {
for (typename std::vector<ExecutorBufInfo>::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));
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions async/as/MPIScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scheduled*>::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;
Expand Down
5 changes: 3 additions & 2 deletions async/as/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ class Thread : public ThreadBase<Executor, InitParameter, Parameter> {

private:
void resetBufferPosition() {
for (typename std::vector<BufInfo>::iterator it = m_buffer.begin(); it != m_buffer.end(); ++it)
it->position = 0;
for (auto& buffer : m_buffer) {
buffer.position = 0;
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion async/as/ThreadBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class ThreadBase : public Base<Executor, InitParameter, Parameter> {
void wait() override {
// wait for the previous call to finish
lock_spinlock(&m_writerLock);

// signal wait
m_waiting = true;
pthread_mutex_unlock(&m_readerLock);
Expand Down

0 comments on commit 4941d7d

Please sign in to comment.