profilingTrigger.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2009-2016 Bernhard Gschaider
9  Copyright (C) 2016-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "profiling.H"
30 #include "profilingTrigger.H"
31 #include "profilingInformation.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 :
37  ptr_(nullptr)
38 {}
39 
40 
42 :
43  ptr_(profiling::New(name))
44 {}
45 
46 
48 :
49  ptr_(profiling::New(name))
50 {}
51 
52 
53 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 
56 {
57  stop();
58 }
59 
60 
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 
64 {
65  return ptr_;
66 }
67 
68 
70 {
71  if (ptr_)
72  {
73  // profiling info pointer managed by pool storage, so no delete here
74  profiling::unstack(ptr_);
75  }
76 
77  ptr_ = nullptr;
78 }
79 
80 
81 // ************************************************************************* //
profiling.H
Foam::profilingTrigger::profilingTrigger
profilingTrigger()
Default construct, no profiling trigger.
Definition: profilingTrigger.C:35
Foam::profilingTrigger::stop
void stop()
Stop triggered profiling.
Definition: profilingTrigger.C:69
Foam::profilingTrigger::running
bool running() const
True if the triggered profiling is active.
Definition: profilingTrigger.C:63
profilingInformation.H
Foam::profilingTrigger::~profilingTrigger
~profilingTrigger()
Destructor.
Definition: profilingTrigger.C:55
Foam::profiling::unstack
static void unstack(const profilingInformation *info)
Remove the information from the top of the stack.
Definition: profiling.C:206
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::profiling
Code profiling.
Definition: profiling.H:82
profilingTrigger.H