doc: Update ck_ring manual pages.

ck_pring
Samy Al Bahra 11 years ago
parent 7fa88f8320
commit 86ac63241a

@ -34,7 +34,7 @@ Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ring.h .In ck_ring.h
.Ft bool .Ft bool
.Fn ck_ring_dequeue_spmc "ck_ring_t *ring" "void *result" .Fn ck_ring_dequeue_spmc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *result"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ring_dequeue_spmc 3 .Fn ck_ring_dequeue_spmc 3
@ -44,6 +44,13 @@ pointed to by
in FIFO fashion. The pointer is stored in the pointer in FIFO fashion. The pointer is stored in the pointer
pointed to by pointed to by
.Fa result . .Fa result .
The buffer pointed to by
.Fa buffer
must be unique to
.Fa ring .
The decoupling of the ring from the buffer serves
to address use-cases involving multiple address spaces
and DMA, among others.
If you are on non-POSIX platforms or wish for strict If you are on non-POSIX platforms or wish for strict
compliance with C, then it is recommended to pass a compliance with C, then it is recommended to pass a
pointer of type void ** for pointer of type void ** for
@ -66,13 +73,16 @@ guarantees.
/* This ring was previously initialized with ck_ring_init. */ /* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring; ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void void
dequeue(void) dequeue(void)
{ {
void *result; void *result;
/* Dequeue from ring until it is empty. */ /* Dequeue from ring until it is empty. */
while (ck_ring_dequeue_spmc(&ring, &result) == true) { while (ck_ring_dequeue_spmc(&ring, &buffer, &result) == true) {
/* /*
* Results contains the oldest pointer in ring * Results contains the oldest pointer in ring
* since the dequeue operation returned true. * since the dequeue operation returned true.

@ -34,7 +34,7 @@ Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ring.h .In ck_ring.h
.Ft bool .Ft bool
.Fn ck_ring_dequeue_spsc "ck_ring_t *ring" "void *result" .Fn ck_ring_dequeue_spsc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *result"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ring_dequeue_spsc 3 .Fn ck_ring_dequeue_spsc 3
@ -44,6 +44,15 @@ pointed to by
in FIFO fashion. The pointer is stored in the pointer in FIFO fashion. The pointer is stored in the pointer
pointed to by pointed to by
.Fa result . .Fa result .
The buffer pointed to by
.Fa buffer
must be unique to
.Fa ring
and point to an array of ck_ring_buffer_t of sufficient
length (according to the power-of-2 elements in the buffer).
The decoupling of the ring from the buffer serves
to address use-cases involving multiple address spaces
and DMA, among others.
If you are on non-POSIX platforms or wish for strict If you are on non-POSIX platforms or wish for strict
compliance with C, then it is recommended to pass a compliance with C, then it is recommended to pass a
pointer of type void ** for pointer of type void ** for
@ -62,13 +71,16 @@ guarantees.
/* This ring was previously initialized with ck_ring_init. */ /* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring; ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void void
dequeue(void) dequeue(void)
{ {
void *result; void *result;
/* Dequeue from ring until it is empty. */ /* Dequeue from ring until it is empty. */
while (ck_ring_dequeue_spsc(&ring, &result) == true) { while (ck_ring_dequeue_spsc(&ring, &buffer, &result) == true) {
/* /*
* Results contains the oldest pointer in ring * Results contains the oldest pointer in ring
* since the dequeue operation returned true. * since the dequeue operation returned true.

@ -34,7 +34,7 @@ Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ring.h .In ck_ring.h
.Ft bool .Ft bool
.Fn ck_ring_enqueue_spmc "ck_ring_t *ring" "void *entry" .Fn ck_ring_enqueue_spmc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ring_enqueue_spmc 3 .Fn ck_ring_enqueue_spmc 3
@ -43,6 +43,15 @@ function enqueues the pointer
into the bounded buffer pointed to by into the bounded buffer pointed to by
.Fa ring .Fa ring
in FIFO fashion. in FIFO fashion.
The buffer pointed to by
.Fa buffer
must be unique to
.Fa ring
and point to an array of ck_ring_buffer_t of sufficient
length (according to the power-of-2 elements in the buffer).
The decoupling of the ring from the buffer serves
to address use-cases involving multiple address spaces
and DMA, among others.
If you are on non-POSIX platforms or wish for strict If you are on non-POSIX platforms or wish for strict
compliance with C, then it is recommended to pass a compliance with C, then it is recommended to pass a
pointer of type void ** for pointer of type void ** for
@ -61,13 +70,16 @@ guarantees for one active invocation.
/* This ring was previously initialized with ck_ring_init. */ /* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring; ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void void
enqueue(void) enqueue(void)
{ {
void *entry = some_object; void *entry = some_object;
/* Attempt to enqueue pointer to some_object into buffer. */ /* Attempt to enqueue pointer to some_object into buffer. */
if (ck_ring_enqueue_spmc(&ring, &entry) == false) { if (ck_ring_enqueue_spmc(&ring, &buffer, &entry) == false) {
/* /*
* The buffer was full and the enqueue operation * The buffer was full and the enqueue operation
* has failed. * has failed.

@ -34,7 +34,7 @@ Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ring.h .In ck_ring.h
.Ft bool .Ft bool
.Fn ck_ring_enqueue_spmc_size "ck_ring_t *ring" "void *entry" "unsigned int *length" .Fn ck_ring_enqueue_spmc_size "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry" "unsigned int *length"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ring_enqueue_spmc 3 .Fn ck_ring_enqueue_spmc 3
@ -43,6 +43,15 @@ function enqueues the pointer
into the bounded buffer pointed to by into the bounded buffer pointed to by
.Fa ring .Fa ring
in FIFO fashion. in FIFO fashion.
The buffer pointed to by
.Fa buffer
must be unique to
.Fa ring
and point to an array of ck_ring_buffer_t of sufficient
length (according to the power-of-2 elements in the buffer).
The decoupling of the ring from the buffer serves
to address use-cases involving multiple address spaces
and DMA, among others.
If you are on non-POSIX platforms or wish for strict If you are on non-POSIX platforms or wish for strict
compliance with C, then it is recommended to pass a compliance with C, then it is recommended to pass a
pointer of type void ** for pointer of type void ** for
@ -61,6 +70,9 @@ guarantees for one active invocation.
/* This ring was previously initialized with ck_ring_init. */ /* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring; ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void void
enqueue(void) enqueue(void)
{ {
@ -68,7 +80,7 @@ enqueue(void)
unsigned int length; unsigned int length;
/* Attempt to enqueue pointer to some_object into buffer. */ /* Attempt to enqueue pointer to some_object into buffer. */
if (ck_ring_enqueue_spmc_size(&ring, &entry, &length) == false) { if (ck_ring_enqueue_spmc_size(&ring, &buffer, &entry, &length) == false) {
/* /*
* The buffer was full and the enqueue operation * The buffer was full and the enqueue operation
* has failed. * has failed.

@ -34,7 +34,7 @@ Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ring.h .In ck_ring.h
.Ft bool .Ft bool
.Fn ck_ring_enqueue_spsc "ck_ring_t *ring" "void *entry" .Fn ck_ring_enqueue_spsc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ring_enqueue_spsc 3 .Fn ck_ring_enqueue_spsc 3
@ -43,6 +43,15 @@ function enqueues the pointer
into the bounded buffer pointed to by into the bounded buffer pointed to by
.Fa ring .Fa ring
in FIFO fashion. in FIFO fashion.
The buffer pointed to by
.Fa buffer
must be unique to
.Fa ring
and point to an array of ck_ring_buffer_t of sufficient
length (according to the power-of-2 elements in the buffer).
The decoupling of the ring from the buffer serves
to address use-cases involving multiple address spaces
and DMA, among others.
If you are on non-POSIX platforms or wish for strict If you are on non-POSIX platforms or wish for strict
compliance with C, then it is recommended to pass a compliance with C, then it is recommended to pass a
pointer of type void ** for pointer of type void ** for
@ -59,13 +68,16 @@ guarantees.
/* This ring was previously initialized with ck_ring_init. */ /* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring; ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void void
enqueue(void) enqueue(void)
{ {
void *entry = some_object; void *entry = some_object;
/* Attempt to enqueue pointer to some_object into buffer. */ /* Attempt to enqueue pointer to some_object into buffer. */
if (ck_ring_enqueue_spsc(&ring, &entry) == false) { if (ck_ring_enqueue_spsc(&ring, &buffer, &entry) == false) {
/* /*
* The buffer was full and the enqueue operation * The buffer was full and the enqueue operation
* has failed. * has failed.

@ -34,7 +34,7 @@ Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ring.h .In ck_ring.h
.Ft bool .Ft bool
.Fn ck_ring_enqueue_spsc_size "ck_ring_t *ring" "void *entry" "unsigned int *size" .Fn ck_ring_enqueue_spsc_size "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry" "unsigned int *size"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ring_enqueue_spsc_size 3 .Fn ck_ring_enqueue_spsc_size 3
@ -43,6 +43,15 @@ function enqueues the pointer
into the bounded buffer pointed to by into the bounded buffer pointed to by
.Fa ring .Fa ring
in FIFO fashion. in FIFO fashion.
The buffer pointed to by
.Fa buffer
must be unique to
.Fa ring
and point to an array of ck_ring_buffer_t of sufficient
length (according to the power-of-2 elements in the buffer).
The decoupling of the ring from the buffer serves
to address use-cases involving multiple address spaces
and DMA, among others.
If you are on non-POSIX platforms or wish for strict If you are on non-POSIX platforms or wish for strict
compliance with C, then it is recommended to pass a compliance with C, then it is recommended to pass a
pointer of type void ** for pointer of type void ** for
@ -59,6 +68,9 @@ guarantees.
/* This ring was previously initialized with ck_ring_init. */ /* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring; ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void void
enqueue(void) enqueue(void)
{ {
@ -66,7 +78,7 @@ enqueue(void)
unsigned int length; unsigned int length;
/* Attempt to enqueue pointer to some_object into buffer. */ /* Attempt to enqueue pointer to some_object into buffer. */
if (ck_ring_enqueue_spsc(&ring, &entry, &length) == false) { if (ck_ring_enqueue_spsc(&ring, &buffer, &entry, &length) == false) {
/* /*
* The buffer was full and the enqueue operation * The buffer was full and the enqueue operation
* has failed. * has failed.

@ -34,7 +34,7 @@ Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ring.h .In ck_ring.h
.Ft bool .Ft bool
.Fn ck_ring_trydequeue_spmc "ck_ring_t *ring" "void *result" .Fn ck_ring_trydequeue_spmc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *result"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ring_trydequeue_spmc 3 .Fn ck_ring_trydequeue_spmc 3
@ -44,6 +44,15 @@ pointed to by
in FIFO fashion. The pointer is stored in the pointer in FIFO fashion. The pointer is stored in the pointer
pointed to by pointed to by
.Fa result . .Fa result .
The buffer pointed to by
.Fa buffer
must be unique to
.Fa ring
and point to an array of ck_ring_buffer_t of sufficient
length (according to the power-of-2 elements in the buffer).
The decoupling of the ring from the buffer serves
to address use-cases involving multiple address spaces
and DMA, among others.
If you are on non-POSIX platforms or wish for strict If you are on non-POSIX platforms or wish for strict
compliance with C, then it is recommended to pass a compliance with C, then it is recommended to pass a
pointer of type void ** for pointer of type void ** for
@ -70,13 +79,16 @@ is non-empty. This
/* This ring was previously initialized with ck_ring_init. */ /* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring; ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void void
dequeue(void) dequeue(void)
{ {
void *result; void *result;
/* Dequeue from ring until contention is actively observed. */ /* Dequeue from ring until contention is actively observed. */
while (ck_ring_trydequeue_spmc(&ring, &result) == true) { while (ck_ring_trydequeue_spmc(&ring, &buffer, &result) == true) {
/* /*
* Results contains the oldest pointer in ring * Results contains the oldest pointer in ring
* since the dequeue operation returned true. * since the dequeue operation returned true.

Loading…
Cancel
Save