Belle II Software development
eb_statistics Class Reference

Public Member Functions

 eb_statistics (const char *file_up, int nup, const char *file_down, int ndown)
 
stream_statisticsup ()
 
stream_statisticsup (int i)
 
stream_statisticsdown ()
 
stream_statisticsdown (int i)
 

Private Attributes

int m_n_u
 
int m_n_d
 
int m_fd_u
 
int m_fd_d
 
int m_len_u
 
int m_len_d
 
stream_statisticsm_stat_u
 
stream_statisticsm_stat_d
 

Detailed Description

Definition at line 30 of file mmap_statistics.h.

Constructor & Destructor Documentation

◆ eb_statistics()

eb_statistics ( const char *  file_up,
int  nup,
const char *  file_down,
int  ndown 
)
inline

Definition at line 42 of file mmap_statistics.h.

43 {
44 m_n_u = nup;
45 m_n_d = ndown;
46
47 m_len_u = sizeof(stream_statistics) * m_n_u;
48 m_len_d = sizeof(stream_statistics) * m_n_d;
49
50 m_fd_u = open(file_up, O_RDWR | O_CREAT | O_NOATIME, 0644);
51 assert(m_fd_u >= 0);
52 m_fd_d = open(file_down, O_RDWR | O_CREAT | O_NOATIME, 0644);
53 assert(m_fd_d >= 0);
54
55 stream_statistics buf_u[m_n_u];
56 stream_statistics buf_d[m_n_d];
57
58 memset(buf_u, 0, m_len_u);
59 memset(buf_d, 0, m_len_d);
60
61 int ret;
62
63 ret = write(m_fd_u, buf_u, m_len_u);
64 assert(ret == m_len_u);
65 ret = write(m_fd_d, buf_d, m_len_d);
66 assert(ret == m_len_d);
67
68 m_stat_u = (stream_statistics*)mmap(0, m_len_u, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd_u, 0);
69 assert(m_stat_u != MAP_FAILED);
70 m_stat_d = (stream_statistics*)mmap(0, m_len_d, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd_d, 0);
71 assert(m_stat_d != MAP_FAILED);
72 };

◆ ~eb_statistics()

~eb_statistics ( )
inline

Definition at line 74 of file mmap_statistics.h.

75 {
76 munmap(m_stat_u, m_len_u);
77 munmap(m_stat_d, m_len_d);
78 close(m_fd_u);
79 close(m_fd_d);
80 };

Member Function Documentation

◆ down() [1/2]

stream_statistics * down ( )
inline

Definition at line 92 of file mmap_statistics.h.

93 {
94 return m_stat_d;
95 };

◆ down() [2/2]

stream_statistics & down ( int  i)
inline

Definition at line 97 of file mmap_statistics.h.

98 {
99 return m_stat_d[i];
100 };

◆ up() [1/2]

stream_statistics * up ( )
inline

Definition at line 82 of file mmap_statistics.h.

83 {
84 return m_stat_u;
85 };

◆ up() [2/2]

stream_statistics & up ( int  i)
inline

Definition at line 87 of file mmap_statistics.h.

88 {
89 return m_stat_u[i];
90 };

Member Data Documentation

◆ m_fd_d

int m_fd_d
private

Definition at line 35 of file mmap_statistics.h.

◆ m_fd_u

int m_fd_u
private

Definition at line 34 of file mmap_statistics.h.

◆ m_len_d

int m_len_d
private

Definition at line 37 of file mmap_statistics.h.

◆ m_len_u

int m_len_u
private

Definition at line 36 of file mmap_statistics.h.

◆ m_n_d

int m_n_d
private

Definition at line 33 of file mmap_statistics.h.

◆ m_n_u

int m_n_u
private

Definition at line 32 of file mmap_statistics.h.

◆ m_stat_d

stream_statistics* m_stat_d
private

Definition at line 39 of file mmap_statistics.h.

◆ m_stat_u

stream_statistics* m_stat_u
private

Definition at line 38 of file mmap_statistics.h.


The documentation for this class was generated from the following file: