C Collections

cthreadcomm · Section 3

cchan_send

cchan_send - send a message through the cchan (it blocks)

C Collections (libccollections, -lccollections)

#include <ccollections/cthreadcomm.h>
 
ccol_retval cchan_send(cchan *ch, cmessage *msg);

Sends a message through the channel, waiting as long as it takes for
the queue to have free space. The queue is chosen from the thread that
calls it: The owner thread sends to the cchan_owner_to_workers queue and
any other thread sends to the cchan_workers_to_owner queue. The data is
not copied; its ownership moves to the channel once the message is in
the queue.

ch   Channel to send through
msg  Message to send. On success the ownership of the data moves to the
     channel.

ccol_success       - The message was sent
ccol_invalid_args  - ch 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 chosen direction are turned off

The call blocks until the chosen queue has free space. The direction
is decided from the ID of the calling thread, which is compared with
the ID of the owner that the channel took at creation. If the call
fails, msg->data still belongs to the caller.

cchan_try_send(3), cchan_timed_send(3), cchan_recv(3)