ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
AthenaInterprocess::SharedQueue Class Reference

#include <SharedQueue.h>

Inheritance diagram for AthenaInterprocess::SharedQueue:
Collaboration diagram for AthenaInterprocess::SharedQueue:

Public Member Functions

 SharedQueue ()
 
 SharedQueue (const std::string &name, int max_msg=SHAREDQUEUE_MAX_MSG, std::size_t max_size=MAX_MSG_SIZE, bool do_unlink=true)
 
 SharedQueue (const SharedQueue &other)
 
SharedQueueoperator= (const SharedQueue &other)
 
virtual ~SharedQueue ()
 
std::string name () const
 
virtual bool try_send (const std::string &)
 
virtual bool send (const std::string &)
 
virtual std::string try_receive ()
 
virtual std::string receive ()
 
template<typename T >
bool try_send_basic (T)
 
template<typename T >
bool send_basic (T)
 
template<typename T >
bool try_receive_basic (T &)
 
template<typename T >
bool receive_basic (T &)
 
 operator bool () const
 

Protected Member Functions

boost::interprocess::message_queue * operator-> ()
 

Private Member Functions

void copy (const SharedQueue &other)
 
void destroy ()
 
template<typename T >
bool do_send_basic (T, bool)
 
template<typename T >
bool do_receive_basic (T &, bool)
 

Private Attributes

boost::interprocess::message_queue * m_queue
 
std::string * m_name
 
int * m_count
 

Detailed Description

Definition at line 21 of file SharedQueue.h.

Constructor & Destructor Documentation

◆ SharedQueue() [1/3]

AthenaInterprocess::SharedQueue::SharedQueue ( )

Definition at line 16 of file SharedQueue.cxx.

16  : m_queue( 0 ), m_name( 0 ), m_count( 0 )
17 {
18 /* empty */
19 }

◆ SharedQueue() [2/3]

AthenaInterprocess::SharedQueue::SharedQueue ( const std::string &  name,
int  max_msg = SHAREDQUEUE_MAX_MSG,
std::size_t  max_size = MAX_MSG_SIZE,
bool  do_unlink = true 
)

Definition at line 21 of file SharedQueue.cxx.

21  :
22  m_queue( 0 ), m_name( 0 ), m_count( 0 )
23 {
24  m_queue = new message_queue( open_or_create, name.c_str(), max_msg, max_size );
25  if ( do_unlink )
26  message_queue::remove( name.c_str() );
27 
28  m_count = new int( 1 );
29  m_name = new std::string( name );
30 }

◆ SharedQueue() [3/3]

AthenaInterprocess::SharedQueue::SharedQueue ( const SharedQueue other)

Definition at line 32 of file SharedQueue.cxx.

33 {
34  copy( other );
35 }

◆ ~SharedQueue()

AthenaInterprocess::SharedQueue::~SharedQueue ( )
virtual

Definition at line 47 of file SharedQueue.cxx.

48 {
49  destroy();
50 }

Member Function Documentation

◆ copy()

void AthenaInterprocess::SharedQueue::copy ( const SharedQueue other)
private

Definition at line 53 of file SharedQueue.cxx.

54 {
55  if ( other.m_count ) {
56  *other.m_count += 1;
57  m_count = other.m_count;
58  m_queue = other.m_queue;
59  m_name = other.m_name;
60  } else {
61  m_count = 0;
62  m_queue = 0;
63  m_name = 0;
64  }
65 }

◆ destroy()

void AthenaInterprocess::SharedQueue::destroy ( )
private

Definition at line 67 of file SharedQueue.cxx.

68 {
69  if ( m_count && --*m_count <= 0 ) {
70  delete m_queue; m_queue = 0;
71  // message_queue::remove( m_name->c_str() );
72  delete m_name; m_name = 0;
73  delete m_count; m_count = 0;
74  }
75 }

◆ do_receive_basic()

template<typename T >
bool AthenaInterprocess::SharedQueue::do_receive_basic ( T &  data,
bool  block 
)
private

Definition at line 98 of file SharedQueue.h.

99 {
100  unsigned int priority = 0;
101  std::size_t recvd_size = 0;
102  bool receive_ok = true;
103 
104  try {
105  if(block) {
106  m_queue->receive(&data,sizeof(T),recvd_size,priority);
107  }
108  else {
109  receive_ok = m_queue->try_receive(&data,sizeof(T),recvd_size,priority);
110  }
111  }
112  catch(boost::interprocess::interprocess_exception&) {
113  return false; // TODO: perhaps add a printout or something
114  }
115 
116  return receive_ok;
117 }

◆ do_send_basic()

template<typename T >
bool AthenaInterprocess::SharedQueue::do_send_basic ( data,
bool  block 
)
private

Definition at line 71 of file SharedQueue.h.

72 {
73  bool send_ok = true;
74 
75  try {
76  if(block)
77  m_queue->send(&data, sizeof(data), 0);
78  else
79  send_ok = m_queue->try_send(&data, sizeof(data), 0);
80  }
81  catch(boost::interprocess::interprocess_exception&) {
82  send_ok = false;
83  }
84 
85  return send_ok;
86 }

◆ name()

std::string AthenaInterprocess::SharedQueue::name ( ) const

Definition at line 78 of file SharedQueue.cxx.

79 {
80  if ( m_name )
81  return *m_name;
82  return "";
83 }

◆ operator bool()

AthenaInterprocess::SharedQueue::operator bool ( ) const
inline

Definition at line 49 of file SharedQueue.h.

49  {
50  return (bool)m_queue;
51  }

◆ operator->()

boost::interprocess::message_queue* AthenaInterprocess::SharedQueue::operator-> ( )
inlineprotected

Definition at line 54 of file SharedQueue.h.

54  {
55  return m_queue;
56  }

◆ operator=()

SharedQueue & AthenaInterprocess::SharedQueue::operator= ( const SharedQueue other)

Definition at line 37 of file SharedQueue.cxx.

38 {
39  if ( &other != this ) {
40  destroy();
41  copy( other );
42  }
43 
44  return *this;
45 }

◆ receive()

std::string AthenaInterprocess::SharedQueue::receive ( )
virtual

Reimplemented in AthenaInterprocess::IdentifiedSharedQueue.

Definition at line 145 of file SharedQueue.cxx.

146 {
147  return do_receive( m_queue, true );
148 }

◆ receive_basic()

template<typename T >
bool AthenaInterprocess::SharedQueue::receive_basic ( T &  data)

Definition at line 124 of file SharedQueue.h.

125 {
126  return do_receive_basic(data,true);
127 }

◆ send()

bool AthenaInterprocess::SharedQueue::send ( const std::string &  buf)
virtual

Reimplemented in AthenaInterprocess::IdentifiedSharedQueue.

Definition at line 107 of file SharedQueue.cxx.

108 {
109  return do_send( m_queue, buf, true );
110 }

◆ send_basic()

template<typename T >
bool AthenaInterprocess::SharedQueue::send_basic ( data)

Definition at line 93 of file SharedQueue.h.

94 {
95  return do_send_basic<T>(data,true);
96 }

◆ try_receive()

std::string AthenaInterprocess::SharedQueue::try_receive ( )
virtual

Reimplemented in AthenaInterprocess::IdentifiedSharedQueue.

Definition at line 140 of file SharedQueue.cxx.

141 {
142  return do_receive( m_queue, false );
143 }

◆ try_receive_basic()

template<typename T >
bool AthenaInterprocess::SharedQueue::try_receive_basic ( T &  data)

Definition at line 119 of file SharedQueue.h.

120 {
121  return do_receive_basic(data,false);
122 }

◆ try_send()

bool AthenaInterprocess::SharedQueue::try_send ( const std::string &  buf)
virtual

Reimplemented in AthenaInterprocess::IdentifiedSharedQueue.

Definition at line 102 of file SharedQueue.cxx.

103 {
104  return do_send( m_queue, buf, false );
105 }

◆ try_send_basic()

template<typename T >
bool AthenaInterprocess::SharedQueue::try_send_basic ( data)

Definition at line 88 of file SharedQueue.h.

89 {
90  return do_send_basic<T>(data,false);
91 }

Member Data Documentation

◆ m_count

int* AthenaInterprocess::SharedQueue::m_count
private

Definition at line 68 of file SharedQueue.h.

◆ m_name

std::string* AthenaInterprocess::SharedQueue::m_name
private

Definition at line 67 of file SharedQueue.h.

◆ m_queue

boost::interprocess::message_queue* AthenaInterprocess::SharedQueue::m_queue
private

Definition at line 66 of file SharedQueue.h.


The documentation for this class was generated from the following files:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
AthenaInterprocess::SharedQueue::m_name
std::string * m_name
Definition: SharedQueue.h:67
AthenaInterprocess::SharedQueue::m_queue
boost::interprocess::message_queue * m_queue
Definition: SharedQueue.h:66
AthenaInterprocess::SharedQueue::m_count
int * m_count
Definition: SharedQueue.h:68
AthenaInterprocess::SharedQueue::name
std::string name() const
Definition: SharedQueue.cxx:78
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
AthenaInterprocess::SharedQueue::destroy
void destroy()
Definition: SharedQueue.cxx:67
python.selector.AtlRunQuerySelectorLhcOlc.priority
priority
Definition: AtlRunQuerySelectorLhcOlc.py:611
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
AthenaInterprocess::SharedQueue::do_receive_basic
bool do_receive_basic(T &, bool)
Definition: SharedQueue.h:98
AthenaInterprocess::SharedQueue::copy
void copy(const SharedQueue &other)
Definition: SharedQueue.cxx:53
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35