ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaInterprocess::IdentifiedSharedQueue Class Reference

#include <IdentifiedSharedQueue.h>

Inheritance diagram for AthenaInterprocess::IdentifiedSharedQueue:
Collaboration diagram for AthenaInterprocess::IdentifiedSharedQueue:

Public Member Functions

 IdentifiedSharedQueue ()
 IdentifiedSharedQueue (const std::string &name, int max_msg=SHAREDQUEUE_MAX_MSG, std::size_t max_size=MAX_MSG_SIZE, bool do_unlink=true)
virtual bool try_send (const std::string &)
virtual bool send (const std::string &)
virtual std::string try_receive ()
virtual std::string try_receive (pid_t &id)
virtual std::string receive ()
virtual std::string receive (pid_t &id)
std::string name () const
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 14 of file IdentifiedSharedQueue.h.

Constructor & Destructor Documentation

◆ IdentifiedSharedQueue() [1/2]

AthenaInterprocess::IdentifiedSharedQueue::IdentifiedSharedQueue ( )

Definition at line 19 of file IdentifiedSharedQueue.cxx.

19 : SharedQueue()
20{
21/* empty */
22}

◆ IdentifiedSharedQueue() [2/2]

AthenaInterprocess::IdentifiedSharedQueue::IdentifiedSharedQueue ( 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 24 of file IdentifiedSharedQueue.cxx.

24 :
25 SharedQueue( name, max_msg, max_size, do_unlink )
26{
27/* empty */
28}

Member Function Documentation

◆ copy()

void AthenaInterprocess::SharedQueue::copy ( const SharedQueue & other)
privateinherited

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}
boost::interprocess::message_queue * m_queue
Definition SharedQueue.h:66

◆ destroy()

void AthenaInterprocess::SharedQueue::destroy ( )
privateinherited

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 )
privateinherited

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}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11

◆ do_send_basic()

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

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
inherited

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
inlineinherited

Definition at line 49 of file SharedQueue.h.

49 {
50 return (bool)m_queue;
51 }

◆ operator->()

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

Definition at line 54 of file SharedQueue.h.

54 {
55 return m_queue;
56 }

◆ receive() [1/2]

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

Reimplemented from AthenaInterprocess::SharedQueue.

Definition at line 73 of file IdentifiedSharedQueue.cxx.

◆ receive() [2/2]

std::string AthenaInterprocess::IdentifiedSharedQueue::receive ( pid_t & id)
virtual

Definition at line 79 of file IdentifiedSharedQueue.cxx.

80{
81 const std::string& buf = this->SharedQueue::receive();
82 return get_pid( buf, id );
83}
virtual std::string receive()
std::string get_pid(const std::string &buf, pid_t &pid)

◆ receive_basic()

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

Definition at line 124 of file SharedQueue.h.

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

◆ send()

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

Reimplemented from AthenaInterprocess::SharedQueue.

Definition at line 43 of file IdentifiedSharedQueue.cxx.

44{
45 return this->SharedQueue::send( add_pid( buf ) );
46}
virtual bool send(const std::string &)
std::string add_pid(const std::string &buf)

◆ send_basic()

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

Definition at line 93 of file SharedQueue.h.

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

◆ try_receive() [1/2]

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

Reimplemented from AthenaInterprocess::SharedQueue.

Definition at line 61 of file IdentifiedSharedQueue.cxx.

62{
63 pid_t pid;
64 return try_receive( pid );
65}

◆ try_receive() [2/2]

std::string AthenaInterprocess::IdentifiedSharedQueue::try_receive ( pid_t & id)
virtual

Definition at line 67 of file IdentifiedSharedQueue.cxx.

68{
69 const std::string& buf = this->SharedQueue::try_receive();
70 return get_pid( buf, id );
71}
virtual std::string try_receive()

◆ try_receive_basic()

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

Definition at line 119 of file SharedQueue.h.

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

◆ try_send()

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

Reimplemented from AthenaInterprocess::SharedQueue.

Definition at line 38 of file IdentifiedSharedQueue.cxx.

39{
40 return this->SharedQueue::try_send( add_pid( buf ) );
41}
virtual bool try_send(const std::string &)

◆ try_send_basic()

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

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
privateinherited

Definition at line 68 of file SharedQueue.h.

◆ m_name

std::string* AthenaInterprocess::SharedQueue::m_name
privateinherited

Definition at line 67 of file SharedQueue.h.

◆ m_queue

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

Definition at line 66 of file SharedQueue.h.


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