Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::interprocess::message_queue_t< VoidPointer > Class Template Reference

A class that allows sending messages between processes. More...

#include <message_queue.hpp>

Public Types

typedef VoidPointer void_pointer
 
typedef
boost::intrusive::pointer_traits
< void_pointer >::template
rebind_pointer< char >::type 
char_ptr
 
typedef
boost::intrusive::pointer_traits
< char_ptr >::difference_type 
difference_type
 
typedef boost::make_unsigned
< difference_type >::type 
size_type
 

Public Member Functions

 message_queue_t (create_only_t create_only, const char *name, size_type max_num_msg, size_type max_msg_size, const permissions &perm=permissions())
 Creates a process shared message queue with name "name". More...
 
 message_queue_t (open_or_create_t open_or_create, const char *name, size_type max_num_msg, size_type max_msg_size, const permissions &perm=permissions())
 Opens or creates a process shared message queue with name "name". More...
 
 message_queue_t (open_only_t open_only, const char *name)
 Opens a previously created process shared message queue with name "name". More...
 
 ~message_queue_t ()
 Destroys *this and indicates that the calling process is finished using the resource. More...
 
void send (const void *buffer, size_type buffer_size, unsigned int priority)
 Sends a message stored in buffer "buffer" with size "buffer_size" in the message queue with priority "priority". More...
 
bool try_send (const void *buffer, size_type buffer_size, unsigned int priority)
 Sends a message stored in buffer "buffer" with size "buffer_size" through the message queue with priority "priority". More...
 
bool timed_send (const void *buffer, size_type buffer_size, unsigned int priority, const boost::posix_time::ptime &abs_time)
 Sends a message stored in buffer "buffer" with size "buffer_size" in the message queue with priority "priority". More...
 
void receive (void *buffer, size_type buffer_size, size_type &recvd_size, unsigned int &priority)
 Receives a message from the message queue. More...
 
bool try_receive (void *buffer, size_type buffer_size, size_type &recvd_size, unsigned int &priority)
 Receives a message from the message queue. More...
 
bool timed_receive (void *buffer, size_type buffer_size, size_type &recvd_size, unsigned int &priority, const boost::posix_time::ptime &abs_time)
 Receives a message from the message queue. More...
 
size_type get_max_msg () const
 Returns the maximum number of messages allowed by the queue. More...
 
size_type get_max_msg_size () const
 Returns the maximum size of message allowed by the queue. More...
 
size_type get_num_msg () const
 Returns the number of messages currently stored. More...
 

Static Public Member Functions

static bool remove (const char *name)
 Removes the message queue from the system. More...
 

Friends

class ipcdetail::msg_queue_initialization_func_t< VoidPointer >
 

Detailed Description

template<class VoidPointer>
class boost::interprocess::message_queue_t< VoidPointer >

A class that allows sending messages between processes.

Member Typedef Documentation

template<class VoidPointer>
typedef boost::intrusive:: pointer_traits<void_pointer>::template rebind_pointer<char>::type boost::interprocess::message_queue_t< VoidPointer >::char_ptr
template<class VoidPointer>
typedef boost::make_unsigned<difference_type>::type boost::interprocess::message_queue_t< VoidPointer >::size_type
template<class VoidPointer>
typedef VoidPointer boost::interprocess::message_queue_t< VoidPointer >::void_pointer

Constructor & Destructor Documentation

template<class VoidPointer >
boost::interprocess::message_queue_t< VoidPointer >::message_queue_t ( create_only_t  create_only,
const char *  name,
size_type  max_num_msg,
size_type  max_msg_size,
const permissions perm = permissions() 
)
inline

Creates a process shared message queue with name "name".

For this message queue, the maximum number of messages will be "max_num_msg" and the maximum message size will be "max_msg_size". Throws on error and if the queue was previously created.

template<class VoidPointer >
boost::interprocess::message_queue_t< VoidPointer >::message_queue_t ( open_or_create_t  open_or_create,
const char *  name,
size_type  max_num_msg,
size_type  max_msg_size,
const permissions perm = permissions() 
)
inline

Opens or creates a process shared message queue with name "name".

If the queue is created, the maximum number of messages will be "max_num_msg" and the maximum message size will be "max_msg_size". If queue was previously created the queue will be opened and "max_num_msg" and "max_msg_size" parameters are ignored. Throws on error.

template<class VoidPointer >
boost::interprocess::message_queue_t< VoidPointer >::message_queue_t ( open_only_t  open_only,
const char *  name 
)
inline

Opens a previously created process shared message queue with name "name".

If the queue was not previously created or there are no free resources, throws an error.

template<class VoidPointer >
boost::interprocess::message_queue_t< VoidPointer >::~message_queue_t ( )
inline

Destroys *this and indicates that the calling process is finished using the resource.

All opened message queues are still valid after destruction. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the message queue from the system use remove().

Member Function Documentation

template<class VoidPointer >
message_queue_t< VoidPointer >::size_type boost::interprocess::message_queue_t< VoidPointer >::get_max_msg ( ) const
inline

Returns the maximum number of messages allowed by the queue.

The message queue must be opened or created previously. Otherwise, returns 0. Never throws

References boost::interprocess::ipcdetail::mq_hdr_t< VoidPointer >::m_max_num_msg.

template<class VoidPointer >
message_queue_t< VoidPointer >::size_type boost::interprocess::message_queue_t< VoidPointer >::get_max_msg_size ( ) const
inline

Returns the maximum size of message allowed by the queue.

The message queue must be opened or created previously. Otherwise, returns 0. Never throws

References boost::interprocess::ipcdetail::mq_hdr_t< VoidPointer >::m_max_msg_size.

template<class VoidPointer >
message_queue_t< VoidPointer >::size_type boost::interprocess::message_queue_t< VoidPointer >::get_num_msg ( ) const
inline
template<class VoidPointer >
void boost::interprocess::message_queue_t< VoidPointer >::receive ( void *  buffer,
size_type  buffer_size,
size_type recvd_size,
unsigned int &  priority 
)
inline

Receives a message from the message queue.

The message is stored in buffer "buffer", which has size "buffer_size". The received message has size "recvd_size" and priority "priority". If the message queue is empty the receiver is blocked. Throws interprocess_error on error.

template<class VoidPointer >
bool boost::interprocess::message_queue_t< VoidPointer >::remove ( const char *  name)
inlinestatic

Removes the message queue from the system.

Returns false on error. Never throws

References boost::interprocess::shared_memory_object::remove().

template<class VoidPointer >
void boost::interprocess::message_queue_t< VoidPointer >::send ( const void *  buffer,
size_type  buffer_size,
unsigned int  priority 
)
inline

Sends a message stored in buffer "buffer" with size "buffer_size" in the message queue with priority "priority".

If the message queue is full the sender is blocked. Throws interprocess_error on error.

template<class VoidPointer >
bool boost::interprocess::message_queue_t< VoidPointer >::timed_receive ( void *  buffer,
size_type  buffer_size,
size_type recvd_size,
unsigned int &  priority,
const boost::posix_time::ptime abs_time 
)
inline

Receives a message from the message queue.

The message is stored in buffer "buffer", which has size "buffer_size". The received message has size "recvd_size" and priority "priority". If the message queue is empty the receiver retries until time "abs_time" is reached. Returns true if the message has been successfully sent. Returns false if timeout is reached. Throws interprocess_error on error.

References boost::date_time::pos_infin, and boost::graph::distributed::receive().

template<class VoidPointer >
bool boost::interprocess::message_queue_t< VoidPointer >::timed_send ( const void *  buffer,
size_type  buffer_size,
unsigned int  priority,
const boost::posix_time::ptime abs_time 
)
inline

Sends a message stored in buffer "buffer" with size "buffer_size" in the message queue with priority "priority".

If the message queue is full the sender retries until time "abs_time" is reached. Returns true if the message has been successfully sent. Returns false if timeout is reached. Throws interprocess_error on error.

References boost::date_time::pos_infin, and boost::graph::distributed::send().

template<class VoidPointer >
bool boost::interprocess::message_queue_t< VoidPointer >::try_receive ( void *  buffer,
size_type  buffer_size,
size_type recvd_size,
unsigned int &  priority 
)
inline

Receives a message from the message queue.

The message is stored in buffer "buffer", which has size "buffer_size". The received message has size "recvd_size" and priority "priority". If the message queue is empty the receiver is not blocked and returns false, otherwise returns true. Throws interprocess_error on error.

template<class VoidPointer >
bool boost::interprocess::message_queue_t< VoidPointer >::try_send ( const void *  buffer,
size_type  buffer_size,
unsigned int  priority 
)
inline

Sends a message stored in buffer "buffer" with size "buffer_size" through the message queue with priority "priority".

If the message queue is full the sender is not blocked and returns false, otherwise returns true. Throws interprocess_error on error.

Friends And Related Function Documentation

template<class VoidPointer>
friend class ipcdetail::msg_queue_initialization_func_t< VoidPointer >
friend

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