7 #include <boost/interprocess/ipc/message_queue.hpp>
16 SharedQueue::SharedQueue() : m_queue( 0 ), m_name( 0 ), m_count( 0 )
22 m_queue( 0 ), m_name( 0 ), m_count( 0 )
24 m_queue =
new message_queue( open_or_create,
name.c_str(), max_msg, max_size );
39 if ( &
other !=
this ) {
55 if (
other.m_count ) {
86 static inline bool do_send( message_queue* mq,
const std::string& buf,
bool block )
92 mq->send( buf.data(), buf.size(), 0 );
94 send_ok = mq->try_send( buf.data(), buf.size(), 0 );
95 }
catch ( interprocess_exception&
e ) {
104 return do_send(
m_queue, buf,
false );
109 return do_send(
m_queue, buf,
true );
112 static inline std::string do_receive( message_queue* mq,
bool block )
114 char buf[ MAX_MSG_SIZE ];
117 std::size_t recvd_size = 0;
122 mq->receive( buf, MAX_MSG_SIZE, recvd_size,
priority );
124 result = mq->try_receive( buf, MAX_MSG_SIZE, recvd_size,
priority );
127 if ( recvd_size > MAX_MSG_SIZE )
128 recvd_size = MAX_MSG_SIZE;
131 return std::string( buf, recvd_size );
133 }
catch ( interprocess_exception&
e ) {
142 return do_receive(
m_queue,
false );
147 return do_receive(
m_queue,
true );