Next: 3.10.7 mtx Up: 3.10 Classes Previous: 3.10.5 mem Contents Index
Subsections

- 3.10.6.1 API

##
3.10.6 mq

The mq class implements a simple unidirectional message queue. In addition to putting and getting messages, there are methods that control the ability to get or put. This provides a simple out of band state transition capability.

### 3.10.6.1 API

void mq_new(cw_mq_t *a_mq, cw_mem_t *a_mem, cw_uint32_t a_msg_size):

  Input(s):
    a_mq:
      Pointer to space for a mq.
    a_mem:
      Pointer to the allocator to use internally.
    a_msg_size:
      Size (in bytes) of messages used for all subsequent calls to mq_*get() and mq_put().
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Constructor.

void mq_delete(cw_mq_t *a_mq):

  Input(s):
    a_mq:
      Pointer to a mq.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Destructor.

cw_bool_t mq_tryget(cw_mq_t *a_mq, ...):

  Input(s):
    a_mq:
      Pointer to a mq.
    ...:
      Pointer to space to store a message.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        No messages in the queue, or get is in the stop state.
    *...:
      If retval is FALSE, a message. Otherwise, undefined.
  Exception(s):
    None.
  Description:
    Try to get a message, but return TRUE if none are available.

cw_bool_t mq_timedget(cw_mq_t *a_mq, const struct timespec *a_timeout, ...):

  Input(s):
    a_mq:
      Pointer to a mq.
    a_timeout:
      Timeout, specified as an absolute time interval.
    ...:
      Pointer to space to store a message.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        No messages in the queue, or get is in the stop state.
    *...:
      If retval is FALSE, a message. Otherwise, undefined.
  Exception(s):
    None.
  Description:
    Get a message. If none are available, block until a message is available, or until timeout.

cw_bol_t mq_get(cw_mq_t *a_mq, ...):

  Input(s):
    a_mq:
      Pointer to a mq.
    ...:
      Pointer to space to store a message.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        Get is in the stop state.
    *...:
      If retval is FALSE, a message. Otherwise, undefined.
  Exception(s):
    None.
  Description:
    Get a message. If none are available, block until a message is available.

cw_bool_t mq_put(cw_mq_t *a_mq, ...):

  Input(s):
    a_mq:
      Pointer to a mq.
    ...:
      A message.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        Failure due to put being in the stop state.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Put a message in a_mq.

cw_bool_t mq_get_start(cw_mq_t *a_mq):

  Input(s):
    a_mq:
      Pointer to a mq.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        Error (already in start state).
  Exception(s):
    None.
  Description:
    Change the get operation to the start state ( mq_get() will not return TRUE).

cw_bool_t mq_get_stop(cw_mq_t *a_mq):

  Input(s):
    a_mq:
      Pointer to a mq.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        Error (already in stop state).
  Exception(s):
    None.
  Description:
    Change the get operation to the stop state ( mq_get() will return TRUE).

cw_bool_t mq_put_start(cw_mq_t *a_mq):

  Input(s):
    a_mq:
      Pointer to a mq.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        Error (already in start state).
  Exception(s):
    None.
  Description:
    Change the put operation to the start state ( mq_put() will not return TRUE).

cw_bool_t mq_put_stop(cw_mq_t *a_mq):

  Input(s):
    a_mq:
      Pointer to a mq.
  Output(s):
    retval:
      FALSE:
        Success.
      TRUE:
        Error (already in stop state).
  Exception(s):
    None.
  Description:
    Change the put operation to the stop state ( mq_put() will return TRUE).

Next: 3.10.7 mtx Up: 3.10 Classes Previous: 3.10.5 mem Contents Index