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 |
-------------------------------------------------------------------------------
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;

View File

@ -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;

View File

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

View File

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