class::sys::Mq

class sys::Mq
  : public api::WorkObject

This class is a wrapper for POSIX message queues.

Summary

Mq()

int close()

int create(

const var::ConstString & name,
int oflag,
const fs::Permissions & permissions,
long flags,
long maxmsg,
long msgsize
)

int get_attr(

struct mq_attr & mqstat
)

MqAttributes get_attributes()

bool is_open() const

unsigned message_priority() const

unsigned msg_prio() const

int notify(

const struct sigevent * notification
)

int open(

const var::ConstString & name,
int oflag,
const fs::Permissions & permissions,
const struct mq_attr * attr
)

Mq & operator<<(

const MqAttributes & attributes
)

s32 receive(

char * msg_ptr,
u32 msg_len
)

s32 receive_timed(

char * msg_ptr,
u32 msg_len,
const struct timespec * abs_timeout
)

int send(

const char * msg_ptr,
u32 msg_len,
unsigned msg_prio
)

int send_timed(

const char * msg_ptr,
u32 msg_len,
unsigned msg_prio,
const struct timespec * abs_timeout
)

int set_attributes(

const struct mq_attr * mqstat,
struct mq_attr * omqstat
)

int set_attributes(

const MqAttributes & attributes
)

s32 timedreceive(

char * msg_ptr,
u32 msg_len,
const struct timespec * abs_timeout
)

int timedsend(

const char * msg_ptr,
u32 msg_len,
unsigned msg_prio,
const struct timespec * abs_timeout
)

static int unlink(

const char * name
)

enum flags

Members

Mq()

int close()

int create(

const var::ConstString & name,
int oflag,
const fs::Permissions & permissions,
long flags,
long maxmsg,
long msgsize
)

Creates a new message queue.

Parameters

  • name The name of the queue

  • oflag EXCLUSIVE or 0

  • mode Permissions

  • flags Message queue flags

  • maxmsg Max number of messages

  • msgsize Message size

Returns

Less than zero for an error (use perror())


int get_attr(

struct mq_attr & mqstat
)

Copies message queue attributes to mqstat.


MqAttributes get_attributes()

Returns a copy of the message queue attributes.


bool is_open() const

Returns true if the message queue is open.


unsigned message_priority() const

Returns the message priority of last message received.


unsigned msg_prio() const

int notify(

const struct sigevent * notification
)

Is not currently supported.


int open(

const var::ConstString & name,
int oflag,
const fs::Permissions & permissions,
const struct mq_attr * attr
)

Opens a message queue.

Parameters

  • name The name of the message queue

  • oflag Open flags

  • mode Access mode

  • attr Pointer to attributes

Returns

Less than zero for an error (use perror())


Mq & operator<<(

const MqAttributes & attributes
)


s32 receive(

char * msg_ptr,
u32 msg_len
)

Receives a message from the queue.

Parameters

  • msg_ptr A pointer to the destination message

  • msg_len The number of bytes available in msg_ptr

Returns

The number of bytes read


s32 receive_timed(

char * msg_ptr,
u32 msg_len,
const struct timespec * abs_timeout
)


int send(

const char * msg_ptr,
u32 msg_len,
unsigned msg_prio
)

Sends a message to the queue.

Parameters

  • msg_ptr A pointer to the message to send

  • msg_len The number of bytes to send

  • msg_prio The message priority (default is 0, lowest priority)

Returns

The number of bytes sent


int send_timed(

const char * msg_ptr,
u32 msg_len,
unsigned msg_prio,
const struct timespec * abs_timeout
)


int set_attributes(

const struct mq_attr * mqstat,
struct mq_attr * omqstat
)


int set_attributes(

const MqAttributes & attributes
)

Sets the message queue attributes.

The flags() value can be set using this method.

The maxmsg(), msgsize() and curmsgs() are ignored (these properties are not mutable.


s32 timedreceive(

char * msg_ptr,
u32 msg_len,
const struct timespec * abs_timeout
)


int timedsend(

const char * msg_ptr,
u32 msg_len,
unsigned msg_prio,
const struct timespec * abs_timeout
)

Send a message to the queue with a timeout


const char * name
)

Deletes a named message queue.


enum flags
  • CREATE Create a new message queue.
  • EXCL Create exclusively.
  • EXCLUSIVE Create exclusively.

Bitwise flags for open()


X

Thanks for Coming!

Subscribe to news and updates