CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::ThreadSafeOutputFileStream Class Reference

#include <ThreadSafeOutputFileStream.h>

Public Member Functions

 operator bool () const
 
 ThreadSafeOutputFileStream (std::string const &name)
 
void write (std::string &&msg)
 
 ~ThreadSafeOutputFileStream ()
 

Private Attributes

std::ofstream file_
 
std::atomic< bool > msgBeingLogged_ {false}
 
tbb::concurrent_queue< std::string > waitingMessages_ {}
 

Detailed Description

Definition at line 11 of file ThreadSafeOutputFileStream.h.

Constructor & Destructor Documentation

edm::ThreadSafeOutputFileStream::ThreadSafeOutputFileStream ( std::string const &  name)

Definition at line 7 of file ThreadSafeOutputFileStream.cc.

edm::ThreadSafeOutputFileStream::~ThreadSafeOutputFileStream ( )

Definition at line 11 of file ThreadSafeOutputFileStream.cc.

References file_, AlCaHLTBitMon_QueryRunRegistry::string, tmp, and waitingMessages_.

12  {
14  while (waitingMessages_.try_pop(tmp)) {
15  file_ << tmp;
16  }
17  file_.close();
18  }
tbb::concurrent_queue< std::string > waitingMessages_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100

Member Function Documentation

edm::ThreadSafeOutputFileStream::operator bool ( ) const
inlineexplicit

Definition at line 17 of file ThreadSafeOutputFileStream.h.

References file_.

17 { return static_cast<bool>(file_); }
void edm::ThreadSafeOutputFileStream::write ( std::string &&  msg)

Definition at line 21 of file ThreadSafeOutputFileStream.cc.

References file_, eostools::move(), mps_check::msg, msgBeingLogged_, AlCaHLTBitMon_QueryRunRegistry::string, tmp, and waitingMessages_.

Referenced by pkg.AbstractPkg::generate(), edm::service::StallMonitor::postBeginJob(), edm::service::StallMonitor::postEvent(), edm::service::StallMonitor::postEventReadFromSource(), edm::service::StallMonitor::postModuleEvent(), edm::service::StallMonitor::postModuleEventAcquire(), edm::service::StallMonitor::postModuleEventPrefetching(), edm::service::StallMonitor::postSourceEvent(), edm::service::StallMonitor::preEvent(), edm::service::StallMonitor::preEventReadFromSource(), edm::service::StallMonitor::preModuleEvent(), edm::service::StallMonitor::preModuleEventAcquire(), edm::service::StallMonitor::preSourceEvent(), and edm::service::StallMonitor::StallMonitor().

22  {
24  bool expected {false};
25  if (msgBeingLogged_.compare_exchange_strong(expected, true)) {
27  while (waitingMessages_.try_pop(tmp)) {
28  file_ << tmp;
29  }
30  msgBeingLogged_.store(false);
31  }
32  }
tbb::concurrent_queue< std::string > waitingMessages_
tuple msg
Definition: mps_check.py:277
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

std::ofstream edm::ThreadSafeOutputFileStream::file_
private

Definition at line 20 of file ThreadSafeOutputFileStream.h.

Referenced by operator bool(), write(), and ~ThreadSafeOutputFileStream().

std::atomic<bool> edm::ThreadSafeOutputFileStream::msgBeingLogged_ {false}
private

Definition at line 21 of file ThreadSafeOutputFileStream.h.

Referenced by write().

tbb::concurrent_queue<std::string> edm::ThreadSafeOutputFileStream::waitingMessages_ {}
private

Definition at line 22 of file ThreadSafeOutputFileStream.h.

Referenced by write(), and ~ThreadSafeOutputFileStream().