ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
atomic_output Class Reference

#include <PileUpMTAlg.h>

Collaboration diagram for atomic_output:

Public Member Functions

 atomic_output ()=default
 
void init (const std::string &filename)
 
 ~atomic_output ()
 
void print (const fmt::memory_buffer &str)
 

Private Attributes

std::FILE * m_file {}
 
std::mutex m_mtx {}
 

Detailed Description

Definition at line 35 of file PileUpMTAlg.h.

Constructor & Destructor Documentation

◆ atomic_output()

atomic_output::atomic_output ( )
default

◆ ~atomic_output()

atomic_output::~atomic_output ( )
inline

Definition at line 53 of file PileUpMTAlg.h.

53  {
54  std::lock_guard lck{m_mtx};
55  if (m_file != nullptr) {
56  std::fclose(m_file);
57  m_file = nullptr;
58  }
59  }

Member Function Documentation

◆ init()

void atomic_output::init ( const std::string &  filename)
inline

Definition at line 42 of file PileUpMTAlg.h.

42  {
43  using namespace std::chrono;
44  std::lock_guard lck{m_mtx};
45  if (m_file != nullptr) {
46  return;
47  }
48  m_file = std::fopen(filename.c_str(), "a");
49  auto time = fmt::localtime(system_clock::to_time_t(system_clock::now()));
50  fmt::print(m_file, ("FILE CREATED ON {:%Y-%m-%d} at {:%H:%M:%S %Z}\n"),
51  time, time);
52  }

◆ print()

void atomic_output::print ( const fmt::memory_buffer &  str)
inline

Definition at line 61 of file PileUpMTAlg.h.

61  {
62  std::lock_guard lck{m_mtx};
63  std::fwrite(str.data(), sizeof(char), str.size(), m_file);
64  std::fflush(m_file);
65  }

Member Data Documentation

◆ m_file

std::FILE* atomic_output::m_file {}
private

Definition at line 37 of file PileUpMTAlg.h.

◆ m_mtx

std::mutex atomic_output::m_mtx {}
private

Definition at line 38 of file PileUpMTAlg.h.


The documentation for this class was generated from the following file:
atomic_output::m_file
std::FILE * m_file
Definition: PileUpMTAlg.h:37
atomic_output::m_mtx
std::mutex m_mtx
Definition: PileUpMTAlg.h:38
python.handimod.now
now
Definition: handimod.py:675
python.fprint.fwrite
def fwrite(f, *args)
Definition: fprint.py:120
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
str
Definition: BTagTrackIpAccessor.cxx:11