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)
edm::ThreadSafeOutputFileStream::~ThreadSafeOutputFileStream ( )

Definition at line 9 of file ThreadSafeOutputFileStream.cc.

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

9  {
11  while (waitingMessages_.try_pop(tmp)) {
12  file_ << tmp;
13  }
14  file_.close();
15  }
tbb::concurrent_queue< std::string > waitingMessages_
tmp
align.sh
Definition: createJobs.py:716

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 17 of file ThreadSafeOutputFileStream.cc.

References file_, eostools::move(), mps_check::msg, msgBeingLogged_, AlCaHLTBitMon_QueryRunRegistry::string, createJobs::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::postModuleGlobalTransition(), edm::service::StallMonitor::postModuleStreamTransition(), edm::service::StallMonitor::postSourceEvent(), edm::service::StallMonitor::preEvent(), edm::service::StallMonitor::preEventReadFromSource(), edm::service::StallMonitor::preModuleEvent(), edm::service::StallMonitor::preModuleEventAcquire(), edm::service::StallMonitor::preModuleGlobalTransition(), edm::service::StallMonitor::preModuleStreamTransition(), edm::service::StallMonitor::preSourceEvent(), and edm::service::StallMonitor::StallMonitor().

17  {
19  bool expected{false};
20  if (msgBeingLogged_.compare_exchange_strong(expected, true)) {
22  while (waitingMessages_.try_pop(tmp)) {
23  file_ << tmp;
24  }
25  msgBeingLogged_.store(false);
26  }
27  }
tbb::concurrent_queue< std::string > waitingMessages_
tuple msg
Definition: mps_check.py:285
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511

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().