Skip to content

Commit 8b01c18

Browse files
authored
Merge pull request #48139 from Dr15Jones/staticTimingServiceBase
Fix static assert warning in TimingServiceBase
2 parents 3ecbfee + 02c1598 commit 8b01c18

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

FWCore/AbstractServices/interface/TimingServiceBase.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ namespace edm {
4242

4343
static void jobStarted();
4444

45-
static std::chrono::steady_clock::time_point jobStartTime() { return s_jobStartTime; }
46-
47-
private:
48-
static std::chrono::steady_clock::time_point s_jobStartTime;
45+
static std::chrono::steady_clock::time_point jobStartTime();
4946
};
5047
} // namespace edm
5148

FWCore/AbstractServices/src/TimingServiceBase.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
using namespace edm;
1616

17-
std::chrono::steady_clock::time_point TimingServiceBase::s_jobStartTime;
18-
1917
void TimingServiceBase::jobStarted() {
20-
if (0 == s_jobStartTime.time_since_epoch().count()) {
21-
s_jobStartTime = std::chrono::steady_clock::now();
22-
}
18+
//make sure the value has been initialized
19+
(void)jobStartTime();
20+
}
21+
22+
std::chrono::steady_clock::time_point TimingServiceBase::jobStartTime() {
23+
static const std::chrono::steady_clock::time_point s_jobStartTime = std::chrono::steady_clock::now();
24+
return s_jobStartTime;
2325
}
2426

2527
//

0 commit comments

Comments
 (0)