Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template message_queue_t

boost::interprocess::message_queue_t

Synopsis

// In header: <boost/interprocess/ipc/message_queue.hpp>

template<typename VoidPointer> 
class message_queue_t {
public:
  // types
  typedef                                                                              ;   
  typedef  ;       
  typedef                            ;
  typedef                            ;      

  // construct/copy/destruct
  (create_only_t, , , , 
                  permissions & = permissions());
  (open_or_create_t, , , , 
                  permissions & = permissions());
  (open_only_t, );
  (create_only_t, , , , 
                  permissions & = permissions());
  (open_or_create_t, , , , 
                  permissions & = permissions());
  (open_only_t, );
  ~();

  // public member functions
   (, , );
   (, , );
  template<typename TimePoint> 
     (, , , );
   (, , , );
   (, , , );
  template<typename TimePoint> 
     (, , , , 
                       );
   () ;
   () ;
   () ;

  // public static functions
   ();
   ();
};

Description

A class that allows sending messages between processes.

message_queue_t public construct/copy/destruct

  1. (create_only_t,  name,  max_num_msg, 
                     max_msg_size, 
                    permissions & perm = permissions());

    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.

  2. (open_or_create_t,  name,  max_num_msg, 
                     max_msg_size, 
                    permissions & perm = permissions());

    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.

  3. (open_only_t,  name);

    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.

  4. (create_only_t,  name,  max_num_msg, 
                     max_msg_size, 
                    permissions & perm = permissions());

    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.

    Note: This function is only available on operating systems with native wchar_t APIs (e.g. Windows).

  5. (open_or_create_t,  name,  max_num_msg, 
                     max_msg_size, 
                    permissions & perm = permissions());

    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.

    Note: This function is only available on operating systems with native wchar_t APIs (e.g. Windows).

  6. (open_only_t,  name);

    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.

    Note: This function is only available on operating systems with native wchar_t APIs (e.g. Windows).

  7. ~();

    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().

message_queue_t public member functions

  1.  ( buffer,  buffer_size,  priority);

    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.

  2.  ( buffer,  buffer_size, 
                   priority);

    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.

  3. template<typename TimePoint> 
       ( buffer,  buffer_size, 
                       priority,  abs_time);

    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.

  4.  ( buffer,  buffer_size,  recvd_size, 
                  priority);

    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.

  5.  ( buffer,  buffer_size,  recvd_size, 
                      priority);

    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.

  6. template<typename TimePoint> 
       ( buffer,  buffer_size, 
                          recvd_size,  priority, 
                          abs_time);

    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.

  7.  () ;

    Returns the maximum number of messages allowed by the queue. The message queue must be opened or created previously. Otherwise, returns 0. Never throws

  8.  () ;

    Returns the maximum size of message allowed by the queue. The message queue must be opened or created previously. Otherwise, returns 0. Never throws

  9.  () ;

    Returns the number of messages currently stored. Never throws

message_queue_t public static functions

  1.  ( name);

    Removes the message queue from the system. Returns false on error. Never throws

  2.  ( name);

    Removes the message queue from the system. Returns false on error. Never throws

    Note: This function is only available on operating systems with native wchar_t APIs (e.g. Windows).


PrevUpHomeNext