STYLE: use stack-like naming for ifEntry handling

STYLE: unique_ptr instead of autoPtr for holding std::thread
This commit is contained in:
Mark Olesen
2022-11-07 11:23:00 +01:00
committed by Andrew Heather
parent e4139898d2
commit c33167dc0e
4 changed files with 21 additions and 21 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -81,7 +81,7 @@ bool Foam::functionEntries::ifEntry::execute
{ {
const label nNested = stack.size(); const label nNested = stack.size();
stack.append(filePos(is.name(), is.lineNumber())); stack.push_back(filePos(is.name(), is.lineNumber()));
// Read line // Read line
string line; string line;
@ -94,8 +94,8 @@ bool Foam::functionEntries::ifEntry::execute
const bool doIf = ifEntry::isTrue(e.stream()); const bool doIf = ifEntry::isTrue(e.stream());
// Info<< "Using #" << typeName << " " << Switch::name(doIf) // Info<< "Using #" << typeName << " " << Switch::name(doIf)
// << " at line " << stack.last().second() // << " at line " << stack.back().second()
// << " in file " << stack.last().first() << endl; // << " in file " << stack.back().first() << endl;
const bool ok = ifeqEntry::execute(doIf, stack, parentDict, is); const bool ok = ifeqEntry::execute(doIf, stack, parentDict, is);
@ -103,8 +103,8 @@ bool Foam::functionEntries::ifEntry::execute
{ {
FatalIOErrorInFunction(parentDict) FatalIOErrorInFunction(parentDict)
<< "Did not find matching #endif for condition starting" << "Did not find matching #endif for condition starting"
<< " at line " << stack.last().second() << " at line " << stack.back().second()
<< " in file " << stack.last().first() << exit(FatalIOError); << " in file " << stack.back().first() << exit(FatalIOError);
} }
return ok; return ok;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -258,9 +258,9 @@ void Foam::functionEntries::ifeqEntry::skipUntil
} }
else if (t.wordToken() == "#if" || t.wordToken() == "#ifeq") 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); skipUntil(stack, parentDict, "#endif", is);
stack.remove(); stack.pop_back();
} }
else if (t.wordToken() == endDirective) else if (t.wordToken() == endDirective)
{ {
@ -310,12 +310,12 @@ bool Foam::functionEntries::ifeqEntry::evaluate
{ {
// Now skip until #endif // Now skip until #endif
skipUntil(stack, parentDict, "#endif", is); skipUntil(stack, parentDict, "#endif", is);
stack.remove(); stack.pop_back();
break; break;
} }
else if (t.wordToken() == "#endif") else if (t.wordToken() == "#endif")
{ {
stack.remove(); stack.pop_back();
break; break;
} }
else else
@ -370,9 +370,9 @@ bool Foam::functionEntries::ifeqEntry::execute
if (t.wordToken() == "#if" || t.wordToken() == "#ifeq") 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); skipUntil(stack, parentDict, "#endif", is);
stack.remove(); stack.pop_back();
} }
else if (t.wordToken() == "#else") else if (t.wordToken() == "#else")
{ {
@ -398,7 +398,7 @@ bool Foam::functionEntries::ifeqEntry::execute
} }
else if (t.wordToken() == "#endif") else if (t.wordToken() == "#endif")
{ {
stack.remove(); stack.pop_back();
break; break;
} }
} }
@ -427,7 +427,7 @@ bool Foam::functionEntries::ifeqEntry::execute
{ {
const label nNested = stack.size(); 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 // Read first token and expand any string
token cond1(is); token cond1(is);
@ -441,8 +441,8 @@ bool Foam::functionEntries::ifeqEntry::execute
// Info<< "Using #" << typeName << " " << cond1 // Info<< "Using #" << typeName << " " << cond1
// << " == " << cond2 // << " == " << cond2
// << " at line " << stack.last().second() // << " at line " << stack.back().second()
// << " in file " << stack.last().first() << endl; // << " in file " << stack.back().first() << endl;
bool ok = ifeqEntry::execute(equal, stack, parentDict, is); bool ok = ifeqEntry::execute(equal, stack, parentDict, is);
@ -450,8 +450,8 @@ bool Foam::functionEntries::ifeqEntry::execute
{ {
FatalIOErrorInFunction(parentDict) FatalIOErrorInFunction(parentDict)
<< "Did not find matching #endif for condition starting" << "Did not find matching #endif for condition starting"
<< " at line " << stack.last().second() << " at line " << stack.back().second()
<< " in file " << stack.last().first() << exit(FatalIOError); << " in file " << stack.back().first() << exit(FatalIOError);
} }
return ok; return ok;

View File

@ -330,7 +330,7 @@ Foam::OFstreamCollator::~OFstreamCollator()
Pout<< "~OFstreamCollator : Waiting for write thread" << endl; Pout<< "~OFstreamCollator : Waiting for write thread" << endl;
} }
thread_->join(); thread_->join();
thread_.clear(); thread_.reset(nullptr);
} }
if (threadComm_ != -1) if (threadComm_ != -1)

View File

@ -130,7 +130,7 @@ class OFstreamCollator
mutable std::mutex mutex_; mutable std::mutex mutex_;
autoPtr<std::thread> thread_; std::unique_ptr<std::thread> thread_;
//- Stack of files to write + contents //- Stack of files to write + contents
FIFOStack<writeData*> objects_; FIFOStack<writeData*> objects_;