From c33167dc0e16ba2f7f9573f59fa326245103e7e0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 7 Nov 2022 11:23:00 +0100 Subject: [PATCH] STYLE: use stack-like naming for ifEntry handling STYLE: unique_ptr instead of autoPtr for holding std::thread --- .../functionEntries/ifEntry/ifEntry.C | 12 ++++----- .../functionEntries/ifeqEntry/ifeqEntry.C | 26 +++++++++---------- .../collatedFileOperation/OFstreamCollator.C | 2 +- .../collatedFileOperation/OFstreamCollator.H | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/ifEntry/ifEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/ifEntry/ifEntry.C index f33e531dcd..2013401efc 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/ifEntry/ifEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/ifEntry/ifEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -81,7 +81,7 @@ bool Foam::functionEntries::ifEntry::execute { const label nNested = stack.size(); - stack.append(filePos(is.name(), is.lineNumber())); + stack.push_back(filePos(is.name(), is.lineNumber())); // Read line string line; @@ -94,8 +94,8 @@ bool Foam::functionEntries::ifEntry::execute const bool doIf = ifEntry::isTrue(e.stream()); // Info<< "Using #" << typeName << " " << Switch::name(doIf) - // << " at line " << stack.last().second() - // << " in file " << stack.last().first() << endl; + // << " at line " << stack.back().second() + // << " in file " << stack.back().first() << endl; const bool ok = ifeqEntry::execute(doIf, stack, parentDict, is); @@ -103,8 +103,8 @@ bool Foam::functionEntries::ifEntry::execute { FatalIOErrorInFunction(parentDict) << "Did not find matching #endif for condition starting" - << " at line " << stack.last().second() - << " in file " << stack.last().first() << exit(FatalIOError); + << " at line " << stack.back().second() + << " in file " << stack.back().first() << exit(FatalIOError); } return ok; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C index 5e77c6c68a..eebfaa1bb1 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -258,9 +258,9 @@ void Foam::functionEntries::ifeqEntry::skipUntil } else if (t.wordToken() == "#if" || t.wordToken() == "#ifeq") { - stack.append(filePos(is.name(), is.lineNumber())); + stack.push_back(filePos(is.name(), is.lineNumber())); skipUntil(stack, parentDict, "#endif", is); - stack.remove(); + stack.pop_back(); } else if (t.wordToken() == endDirective) { @@ -310,12 +310,12 @@ bool Foam::functionEntries::ifeqEntry::evaluate { // Now skip until #endif skipUntil(stack, parentDict, "#endif", is); - stack.remove(); + stack.pop_back(); break; } else if (t.wordToken() == "#endif") { - stack.remove(); + stack.pop_back(); break; } else @@ -370,9 +370,9 @@ bool Foam::functionEntries::ifeqEntry::execute if (t.wordToken() == "#if" || t.wordToken() == "#ifeq") { - stack.append(filePos(is.name(), is.lineNumber())); + stack.push_back(filePos(is.name(), is.lineNumber())); skipUntil(stack, parentDict, "#endif", is); - stack.remove(); + stack.pop_back(); } else if (t.wordToken() == "#else") { @@ -398,7 +398,7 @@ bool Foam::functionEntries::ifeqEntry::execute } else if (t.wordToken() == "#endif") { - stack.remove(); + stack.pop_back(); break; } } @@ -427,7 +427,7 @@ bool Foam::functionEntries::ifeqEntry::execute { const label nNested = stack.size(); - stack.append(filePos(is.name(), is.lineNumber())); + stack.push_back(filePos(is.name(), is.lineNumber())); // Read first token and expand any string token cond1(is); @@ -441,8 +441,8 @@ bool Foam::functionEntries::ifeqEntry::execute // Info<< "Using #" << typeName << " " << cond1 // << " == " << cond2 - // << " at line " << stack.last().second() - // << " in file " << stack.last().first() << endl; + // << " at line " << stack.back().second() + // << " in file " << stack.back().first() << endl; bool ok = ifeqEntry::execute(equal, stack, parentDict, is); @@ -450,8 +450,8 @@ bool Foam::functionEntries::ifeqEntry::execute { FatalIOErrorInFunction(parentDict) << "Did not find matching #endif for condition starting" - << " at line " << stack.last().second() - << " in file " << stack.last().first() << exit(FatalIOError); + << " at line " << stack.back().second() + << " in file " << stack.back().first() << exit(FatalIOError); } return ok; diff --git a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C index 3c2404bd02..8514aeb1e8 100644 --- a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C +++ b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C @@ -330,7 +330,7 @@ Foam::OFstreamCollator::~OFstreamCollator() Pout<< "~OFstreamCollator : Waiting for write thread" << endl; } thread_->join(); - thread_.clear(); + thread_.reset(nullptr); } if (threadComm_ != -1) diff --git a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.H b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.H index 3285e9eb7b..f131cdec28 100644 --- a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.H +++ b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.H @@ -130,7 +130,7 @@ class OFstreamCollator mutable std::mutex mutex_; - autoPtr thread_; + std::unique_ptr thread_; //- Stack of files to write + contents FIFOStack objects_;