C Collections

cthreadcomm · Section 3

ccircq_send

ccircq_send - send a message to the queue (it blocks)

C Collections (libccollections, -lccollections)

#include <ccollections/cthreadcomm.h>
 
ccol_retval ccircq_send(ccircq *cq, cmessage *msg);

Waits until the queue has free space and then puts the message in it.
The data is not copied: Its ownership moves to the queue, and on
success msg->data is set to NULL.

cq   Circular queue to send to
msg  Message to send. On success the ownership of the data moves to the
     queue.

ccol_success       - The message was sent
ccol_invalid_args  - cq or msg is NULL, msg->data is NULL while
                     msg->size is not 0, or msg->data is not NULL
                     while msg->size is 0
ccol_not_permitted - Sends on the queue are turned off

The wait for free space has no time limit, but it ends when sends on
the queue are turned off, because a woken sender checks the send state
again before it goes on. On failure the caller keeps the ownership of
msg->data.
 
msg->data == NULL with msg->size == 0 is valid and works as a sentinel
message. msg->data == NULL with msg->size > 0 is refused, and so is
msg->data != NULL with msg->size == 0, because a live pointer must
carry a payload.

ccircq_try_send(3), ccircq_timed_send(3), ccircq_recv(3)