Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaudi
Gaudi
Commits
4228bfb7
There was a problem fetching the pipeline summary.
Commit
4228bfb7
authored
8 years ago
by
Charles Leggett
Browse files
Options
Downloads
Plain Diff
Made StatEntity more thread safe
See merge request
!275
parents
d19e41b9
d98db978
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!275
Made StatEntity more thread safe
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GaudiKernel/GaudiKernel/StatEntity.h
+7
-0
7 additions, 0 deletions
GaudiKernel/GaudiKernel/StatEntity.h
GaudiKernel/src/Lib/StatEntity.cpp
+27
-0
27 additions, 0 deletions
GaudiKernel/src/Lib/StatEntity.cpp
with
34 additions
and
0 deletions
GaudiKernel/GaudiKernel/StatEntity.h
+
7
−
0
View file @
4228bfb7
...
...
@@ -7,6 +7,7 @@
// ============================================================================
#include
<string>
#include
<iostream>
#include
<mutex>
// ============================================================================
// Gaudi
// ============================================================================
...
...
@@ -83,6 +84,10 @@ public:
const
double
flag2
,
const
double
minFlag
,
const
double
maxFlag
)
;
/// copy constructor
StatEntity
(
const
StatEntity
&
);
/// assignment operator
StatEntity
&
operator
=
(
const
StatEntity
&
);
/// destructor
~
StatEntity
()
=
default
;
// ==========================================================================
...
...
@@ -439,6 +444,8 @@ private:
double
m_se_maximalFlag
;
// DR number of calls before reset
long
m_se_nEntriesBeforeReset
;
// Mutex to protect calls of add/reset/operator++
std
::
mutex
m_mutex
;
// ==========================================================================
};
// ============================================================================
...
...
This diff is collapsed.
Click to expand it.
GaudiKernel/src/Lib/StatEntity.cpp
+
27
−
0
View file @
4228bfb7
...
...
@@ -55,6 +55,30 @@ StatEntity::StatEntity
,
m_se_nEntriesBeforeReset
(
-
1
)
{}
// ============================================================================
// The copy contructor, non default because of atomics
// ============================================================================
StatEntity
::
StatEntity
(
const
StatEntity
&
other
)
:
m_se_nEntries
(
other
.
m_se_nEntries
)
,
m_se_accumulatedFlag
(
other
.
m_se_accumulatedFlag
)
,
m_se_accumulatedFlag2
(
other
.
m_se_accumulatedFlag2
)
,
m_se_minimalFlag
(
other
.
m_se_minimalFlag
)
,
m_se_maximalFlag
(
other
.
m_se_maximalFlag
)
,
m_se_nEntriesBeforeReset
(
other
.
m_se_nEntriesBeforeReset
)
{}
// ============================================================================
// The copy contructor, non default because of atomics
// ============================================================================
StatEntity
&
StatEntity
::
operator
=
(
const
StatEntity
&
other
)
{
m_se_nEntries
=
other
.
m_se_nEntries
;
m_se_accumulatedFlag
=
other
.
m_se_accumulatedFlag
;
m_se_accumulatedFlag2
=
other
.
m_se_accumulatedFlag2
;
m_se_minimalFlag
=
other
.
m_se_minimalFlag
;
m_se_maximalFlag
=
other
.
m_se_maximalFlag
;
m_se_nEntriesBeforeReset
=
other
.
m_se_nEntriesBeforeReset
;
return
*
this
;
}
// ============================================================================
// the internal format description
// ============================================================================
const
std
::
string
&
StatEntity
::
format
()
...
...
@@ -148,6 +172,7 @@ double StatEntity::efficiencyErr () const
// ============================================================================
StatEntity
&
StatEntity
::
operator
+=
(
const
StatEntity
&
other
)
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_mutex
);
m_se_nEntries
+=
other
.
m_se_nEntries
;
m_se_accumulatedFlag
+=
other
.
m_se_accumulatedFlag
;
m_se_accumulatedFlag2
+=
other
.
m_se_accumulatedFlag2
;
...
...
@@ -185,6 +210,7 @@ bool StatEntity::operator< ( const StatEntity& se ) const
// ============================================================================
unsigned
long
StatEntity
::
add
(
const
double
Flag
)
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_mutex
);
//
if
(
0
<
m_se_nEntriesBeforeReset
)
{
--
m_se_nEntriesBeforeReset
;
}
else
if
(
0
==
m_se_nEntriesBeforeReset
)
{
reset
();
}
///< reset everything
...
...
@@ -205,6 +231,7 @@ unsigned long StatEntity::add ( const double Flag )
// ============================================================================
void
StatEntity
::
reset
()
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_mutex
);
//
m_se_nEntries
=
0
;
m_se_accumulatedFlag
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment