CK_RING_ENQUEUE_SPMC(3)
π ck_ring_enqueue_spmc β enqueue pointer into bounded FIFO π
okay bestie, sit down, hydrate, and let me tell you about ck_ring_enqueue_spmc(3) β she's a section 3 manual page, she lives in the Concurrency Kit library, and she is literally the moment.
β¨ LIBRARY β¨
Concurrency Kit β that's libck, and you link her with -lck. π
πΈ SYNOPSIS πΈ
#include <ck_ring.h>
bool
ck_ring_enqueue_spmc(ck_ring_t *ring, ck_ring_buffer_t *buffer,
void *entry);
that's the whole vibe. three args, one bool back, no drama. π
π¦ DESCRIPTION π¦
so what does she do. The ck_ring_enqueue_spmc(3) function enqueues the pointer entry into the bounded buffer pointed to by ring, and she does it FIFO style β first in, first out, no cutting the line, periodt. π
The buffer pointed to by buffer must be unique to ring, and it has to point to an array of ck_ring_buffer_t of sufficient length β sufficient meaning, like, according to the power-of-2 elements in the buffer. no cap, do the math right. π₯
the way that the ring is decoupled from the buffer?? iconic. it's there to serve use-cases involving multiple address spaces and DMA, among others. she's flexible like that. π
okay important bestie note: if you're on non-POSIX platforms, or you're out here wishing for strict compliance with C, then it is recommended that you pass a pointer of typevoid **forentry. do with that what you will. π
safety check: this function is safe to call without locking for UINT_MAX concurrent invocations of ck_ring_dequeue_spmc(3) or ck_ring_trydequeue_spmc(3). UINT_MAX!! she is not fragile. π
and the progress guarantee?? this function provides wait-free progress guarantees for one active invocation. one active invocation, wait-free. slay. β
π EXAMPLE π
here's her in her natural habitat, copy it exactly bestie:
#include <ck_ring.h>
/* This ring was previously initialized with ck_ring_init. */
ck_ring_t ring;
/* The ring was initialized for 1023 elements. */
ck_ring_buffer_t buffer[1024];
void
enqueue(void)
{
void *entry = some_object;
/* Attempt to enqueue pointer to some_object into buffer. */
if (ck_ring_enqueue_spmc(&ring, &buffer, &entry) == false) {
/*
* The buffer was full and the enqueue operation
* has failed.
*/
return;
}
/* Enqueue operation completed successfully. */
return;
}
notice how she's all 1023 elements in a 1024 buffer. that's the power-of-2 thing. she said "leave room for the algorithm, babe." π
π RETURN VALUES π
trueβ yay!! the value ofentrywas successfully enqueued intoring. π«Άfalseβ aw. the value ofentrycould not be enqueued, and this only occurs ifringwas full. that's it, that's the only reason. no other mystery failures, fr fr. π
π SEE ALSO π
go read her friends, they're all main characters:
ck_ring_init(3)ck_ring_dequeue_spmc(3)ck_ring_trydequeue_spmc(3)ck_ring_enqueue_spmc_size(3)ck_ring_dequeue_spsc(3)ck_ring_enqueue_spsc(3)ck_ring_enqueue_spsc_size(3)ck_ring_capacity(3)ck_ring_size(3)
Additional information available at http://concurrencykit.org/ β¨
and that's the page bestie!! this one was dated April 20, 2013, and it's page CK_RING_ENQUEUE_SPMC(3) from the Concurrency Kit crew. mwah, go enqueue something. ππ π§
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- debian bookworm: libck-dev 0.7.1-10 Β· BSD-2-Clause
- debian trixie: libck-dev 0.7.2-6 Β· BSD-2-Clause
- epel 10: ck-devel 0.7.2-1.el10_1 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- epel 9: ck-devel 0.7.0-10.el9 Β· BSD
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- nixos 26.05: ck 0.7.2
- nixpkgs unstable: ck 0.7.2
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- ubuntu jammy: libck-dev 0.7.1-6ubuntu2 Β· BSD-2-Clause
- ubuntu noble: libck-dev 0.7.1-13build1 Β· BSD-2-Clause
- ubuntu questing: libck-dev 0.7.2-5ubuntu1
- ubuntu resolute: libck-dev 0.7.2-5ubuntu2 Β· BSD-2-Clause
- ubuntu stonking: libck-dev 0.7.2-11 Β· BSD-2-Clause
- Copyright 2012-2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms