CK_QUEUE(3)
okay bestie, sit DOWN π«Ά because today we're talking about ck_queue(3) β the Concurrency Kit header that gives you lock-free queues and it's genuinely iconic. No locks. No stress. Just vibes and pointer math. Let's go. π
πΈ NAME πΈ
So ck_queue is a whole family of macros β and yes, she has a big family, we love a big family. Behold, the full roster:
The CK_LIST_ girlies π (multi-reader single-writer singly-linked lists):
CK_LIST_EMPTYCK_LIST_ENTRYCK_LIST_FIRSTCK_LIST_FOREACHCK_LIST_FOREACH_FROMCK_LIST_FOREACH_SAFECK_LIST_HEADCK_LIST_HEAD_INITIALIZERCK_LIST_INITCK_LIST_INSERT_AFTERCK_LIST_INSERT_BEFORECK_LIST_INSERT_HEADCK_LIST_MOVECK_LIST_NEXTCK_LIST_REMOVECK_LIST_SWAP
The CK_SLIST_ crew β¨ (singly-linked, and she does not play about the tail):
CK_SLIST_EMPTYCK_SLIST_ENTRYCK_SLIST_FIRSTCK_SLIST_FOREACHCK_SLIST_FOREACH_FROMCK_SLIST_FOREACH_PREVPTRCK_SLIST_FOREACH_SAFECK_SLIST_HEADCK_SLIST_HEAD_INITIALIZERCK_SLIST_INITCK_SLIST_INSERT_AFTERCK_SLIST_INSERT_HEADCK_SLIST_MOVECK_SLIST_NEXTCK_SLIST_REMOVECK_SLIST_REMOVE_AFTERCK_SLIST_REMOVE_HEADCK_SLIST_SWAP
The CK_STAILQ_ icons π (singly-linked tail queues, the ones who know where the end is):
CK_STAILQ_CONCATCK_STAILQ_EMPTYCK_STAILQ_ENTRYCK_STAILQ_FIRSTCK_STAILQ_FOREACHCK_STAILQ_FOREACH_FROMCK_STAILQ_FOREACH_SAFECK_STAILQ_HEADCK_STAILQ_HEAD_INITIALIZERCK_STAILQ_INITCK_STAILQ_INSERT_AFTERCK_STAILQ_INSERT_HEADCK_STAILQ_INSERT_TAILCK_STAILQ_MOVECK_STAILQ_NEXTCK_STAILQ_REMOVECK_STAILQ_REMOVE_AFTERCK_STAILQ_REMOVE_HEADCK_STAILQ_SWAP
And what do they all do? multi-reader single-writer singly-linked lists, singly-linked tail queues and lists. That's the whole assignment, and she ate. π
π LIBRARY π
This lives in the Concurrency Kit, aka libck, and you link it with -lck. That's the tea. β
β¨ SYNOPSIS β¨
First things first, the include. You need this, don't skip it, it's giving necessary:
#include <ck_queue.h>
Then, every single one of the macro calls, exactly as the universe intended:
CK_LIST_EMPTY();
CK_LIST_ENTRY();
CK_LIST_FIRST();
CK_LIST_FOREACH();
CK_LIST_FOREACH_FROM();
CK_LIST_FOREACH_SAFE();
CK_LIST_HEAD();
CK_LIST_HEAD_INITIALIZER();
CK_LIST_INIT();
CK_LIST_INSERT_AFTER();
CK_LIST_INSERT_BEFORE();
CK_LIST_INSERT_HEAD();
CK_LIST_MOVE();
CK_LIST_NEXT();
CK_LIST_REMOVE();
CK_LIST_SWAP();
CK_SLIST_EMPTY();
CK_SLIST_ENTRY();
CK_SLIST_FIRST();
CK_SLIST_FOREACH();
CK_SLIST_FOREACH_FROM();
CK_SLIST_FOREACH_PREVPTR();
CK_SLIST_FOREACH_SAFE();
CK_SLIST_HEAD();
CK_SLIST_HEAD_INITIALIZER();
CK_SLIST_INIT();
CK_SLIST_INSERT_AFTER();
CK_SLIST_INSERT_HEAD();
CK_SLIST_MOVE();
CK_SLIST_NEXT();
CK_SLIST_REMOVE();
CK_SLIST_REMOVE_AFTER();
CK_SLIST_REMOVE_HEAD();
CK_SLIST_SWAP();
CK_STAILQ_CONCAT();
CK_STAILQ_EMPTY();
CK_STAILQ_ENTRY();
CK_STAILQ_FIRST();
CK_STAILQ_FOREACH();
CK_STAILQ_FOREACH_FROM();
CK_STAILQ_FOREACH_SAFE();
CK_STAILQ_HEAD();
CK_STAILQ_HEAD_INITIALIZER();
CK_STAILQ_INIT();
CK_STAILQ_INSERT_AFTER();
CK_STAILQ_INSERT_HEAD();
CK_STAILQ_INSERT_TAIL();
CK_STAILQ_MOVE();
CK_STAILQ_NEXT();
CK_STAILQ_REMOVE();
CK_STAILQ_REMOVE_AFTER();
CK_STAILQ_REMOVE_HEAD();
CK_STAILQ_SWAP();
π« DESCRIPTION π«
Okay so if you want more detail than this page gives you, go read your system's manual page for queue β that's where the extended lore lives. π
Here's the main character moment though: ck_queue is a queue.h-compatible implementation of many-reader-single-writer queues. Which means β and I need you to understand how good this is β it lets you do safe concurrent iteration, peeking, and read-side access even while there's a single concurrent writer doing her thing, and it does it all with zero locks. No locks. None. Not one. π§
And the best part? In many cases, adopting ck_queue is literally just prefixing all your queue operations with CK_. That's it. That's the glow-up. π
β¨
π SEE ALSO π
queue
Want more? Additional information available at http://concurrencykit.org/ π
That's the page, bestie, you're officially educated. π
This was ck_queue(3), dated July 28, 2013. Go forth and be lock-free, you absolute legend. ππ¦π
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- 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
- 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 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 2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms