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}
 
oneapi::tbb::concurrent_queue< std::string > waitingMessages_ {}
 

Detailed Description

Definition at line 11 of file ThreadSafeOutputFileStream.h.

Constructor & Destructor Documentation

◆ ThreadSafeOutputFileStream()

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

◆ ~ThreadSafeOutputFileStream()

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  }
tmp
align.sh
Definition: createJobs.py:716
oneapi::tbb::concurrent_queue< std::string > waitingMessages_

Member Function Documentation

◆ operator bool()

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

Definition at line 17 of file ThreadSafeOutputFileStream.h.

References file_.

17 { return static_cast<bool>(file_); }

◆ write()

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(), and edm::service::StallMonitor::preSourceEvent().

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  }
tuple msg
Definition: mps_check.py:286
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511
oneapi::tbb::concurrent_queue< std::string > waitingMessages_

Member Data Documentation

◆ file_

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

Definition at line 20 of file ThreadSafeOutputFileStream.h.

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

◆ msgBeingLogged_

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

Definition at line 21 of file ThreadSafeOutputFileStream.h.

Referenced by write().

◆ waitingMessages_

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

Definition at line 22 of file ThreadSafeOutputFileStream.h.

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