1CK_RING_ENQUEUE_SPMC(3)  BSD Library Functions Manual  CK_RING_ENQUEUE_SPMC(3)
2

NAME

4     ck_ring_enqueue_spmc — enqueue pointer into bounded FIFO
5

LIBRARY

7     Concurrency Kit (libck, -lck)
8

SYNOPSIS

10     #include <ck_ring.h>
11
12     bool
13     ck_ring_enqueue_spmc(ck_ring_t *ring, ck_ring_buffer_t *buffer,
14         void *entry);
15

DESCRIPTION

17     The ck_ring_enqueue_spmc(3) function enqueues the pointer entry into the
18     bounded buffer pointed to by ring in FIFO fashion.  The buffer pointed to
19     by buffer must be unique to ring and point to an array of ck_ring_buf‐
20     fer_t of sufficient length (according to the power-of-2 elements in the
21     buffer).  The decoupling of the ring from the buffer serves to address
22     use-cases involving multiple address spaces and DMA, among others.  If
23     you are on non-POSIX platforms or wish for strict compliance with C, then
24     it is recommended to pass a pointer of type void ** for entry.  This
25     function is safe to call without locking for UINT_MAX concurrent invoca‐
26     tions of ck_ring_dequeue_spmc(3) or ck_ring_trydequeue_spmc(3).  This
27     function provides wait-free progress guarantees for one active invoca‐
28     tion.
29

EXAMPLE

31           #include <ck_ring.h>
32
33           /* This ring was previously initialized with ck_ring_init. */
34           ck_ring_t ring;
35
36           /* The ring was initialized for 1023 elements. */
37           ck_ring_buffer_t buffer[1024];
38
39           void
40           enqueue(void)
41           {
42                   void *entry = some_object;
43
44                   /* Attempt to enqueue pointer to some_object into buffer. */
45                   if (ck_ring_enqueue_spmc(&ring, &buffer, &entry) == false) {
46                           /*
47                            * The buffer was full and the enqueue operation
48                            * has failed.
49                            */
50                           return;
51                   }
52
53                   /* Enqueue operation completed successfully. */
54                   return;
55           }
56

RETURN VALUES

58     The function returns true if the value of entry was successfully enqueued
59     into ring.  The function will return false if the value of entry could
60     not be enqueued which only occurs if ring was full.
61

SEE ALSO

63     ck_ring_init(3), ck_ring_dequeue_spmc(3), ck_ring_trydequeue_spmc(3),
64     ck_ring_enqueue_spmc_size(3), ck_ring_dequeue_spsc(3),
65     ck_ring_enqueue_spsc(3), ck_ring_enqueue_spsc_size(3),
66     ck_ring_capacity(3), ck_ring_size(3)
67
68     Additional information available at http://concurrencykit.org/
69
70                                April 20, 2013
Impressum