Main Page
Namespaces
Classes
Package Documentation
FWCore
Concurrency
src
ThreadSafeOutputFileStream.cc
Go to the documentation of this file.
1
#include "
FWCore/Concurrency/interface/ThreadSafeOutputFileStream.h
"
2
3
#include <sstream>
4
5
namespace
edm
{
6
7
ThreadSafeOutputFileStream::ThreadSafeOutputFileStream
(
std::string
const
&
name
) : file_{name} {}
8
9
ThreadSafeOutputFileStream::~ThreadSafeOutputFileStream
() {
10
std::string
tmp
;
11
while
(
waitingMessages_
.try_pop(tmp)) {
12
file_
<<
tmp
;
13
}
14
file_
.close();
15
}
16
17
void
ThreadSafeOutputFileStream::write
(
std::string
&&
msg
) {
18
waitingMessages_
.push(
std::move
(
msg
));
19
bool
expected{
false
};
20
if
(
msgBeingLogged_
.compare_exchange_strong(expected,
true
)) {
21
std::string
tmp
;
22
while
(
waitingMessages_
.try_pop(tmp)) {
23
file_
<<
tmp
;
24
}
25
msgBeingLogged_
.store(
false
);
26
}
27
}
28
}
// namespace edm
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
ThreadSafeOutputFileStream.h
edm::ThreadSafeOutputFileStream::waitingMessages_
tbb::concurrent_queue< std::string > waitingMessages_
Definition:
ThreadSafeOutputFileStream.h:22
edm::ThreadSafeOutputFileStream::msgBeingLogged_
std::atomic< bool > msgBeingLogged_
Definition:
ThreadSafeOutputFileStream.h:21
edm::ThreadSafeOutputFileStream::ThreadSafeOutputFileStream
ThreadSafeOutputFileStream(std::string const &name)
Definition:
ThreadSafeOutputFileStream.cc:7
edm::ThreadSafeOutputFileStream::file_
std::ofstream file_
Definition:
ThreadSafeOutputFileStream.h:20
mps_check.msg
tuple msg
Definition:
mps_check.py:285
tmp
std::vector< std::vector< double > > tmp
Definition:
MVATrainer.cc:100
edm
HLT enums.
Definition:
AlignableModifier.h:17
edm::ThreadSafeOutputFileStream::~ThreadSafeOutputFileStream
~ThreadSafeOutputFileStream()
Definition:
ThreadSafeOutputFileStream.cc:9
dataset.name
name
Definition:
dataset.py:45
edm::ThreadSafeOutputFileStream::write
void write(std::string &&msg)
Definition:
ThreadSafeOutputFileStream.cc:17
eostools.move
def move(src, dest)
Definition:
eostools.py:511
Generated for CMSSW Reference Manual by
1.8.11