C Collections

cthreadcomm · Section 3

cdynmq_recv

cdynmq_recv - receive a message from a dynamic queue (it blocks)

C Collections (libccollections, -lccollections)

#include <ccollections/cthreadcomm.h>
 
ccol_retval cdynmq_recv(cdynmq *dq, cmessage *target_buf);

Waits until the dynamic queue holds a message, then removes the
message at the head and hands it over in target_buf without copying
the data. The data pointer then belongs to the caller, who must free
target_buf->data when done with it.

dq          Dynamic queue to receive from
target_buf  Buffer that gets the message together with the ownership
            of the data.

ccol_success        - A message was received. The caller must free
                      target_buf->data.
ccol_invalid_args   - dq or target_buf is NULL

The wait has no time limit. Turning sends off doesn't wake a waiting
receiver: It stays blocked until sends are turned on again and a
message arrives. The function is thread-safe.

cdynmq_try_recv(3), cdynmq_timed_recv(3), cdynmq_send(3)