CK_COHORT_TRYLOCK(3)
π CK_COHORT_TRYLOCK β try to acquire cohort lock π
okay bestie, welcome to the CK_COHORT_TRYLOCK(3) page, it's giving concurrency, it's giving β¨lock energyβ¨, let's get into it π«Ά
π LIBRARY π
Concurrency Kit, aka libck, and you link it with -lck π
π SYNOPSIS π
#include <ck_cohort.h>
CK_COHORT_TRYLOCK(COHORT_NAME cohort_name, COHORT *cohort,
void *global_trylock_context, void *local_trylock_context,
void *lock_unlock_context);
β¨ DESCRIPTION β¨
so this call right here? it tries to snag both the local lock and the global lock (but only if that's necessary, okay, it's not gonna do extra work for no reason π§) from cohort. iconique behaviour, no cap.
heads up though β you can only use this with cohort types that were defined using the CK_COHORT_TRYLOCK_PROTOTYPE(3) macro. wrong prototype, wrong vibe, it's not gonna work π
the call will not block, periodt. it just returns a bool that evaluates to true iff the cohort was successfully acquired. that's it, that's the whole answer. lowkey elegant fr fr.
here's the tea on the contexts π:
global_trylock_contextgets passed as the second argument to the function that was provided as theglobal_trylock_methodargument toCK_COHORT_TRYLOCK_PROTOTYPEβ but only if that method is actually called πlocal_trylock_contextgets passed to the function specified bylocal_trylock_method- and if the global lock acquisition fails? then the cohort will immediately release its local lock as well π like, no hesitation, it's cleaning up after itself, main character energy honestly. when that happens,
local_unlock_contextgets passed to the function specified bylocal_unlock_methodwhen this call is made.
(and yes bestie, the synopsis says lock_unlock_context while the description says local_unlock_context β that's just how the page is written, iykyk, we're keeping it exactly as it is π)
π SEE ALSO π
ck_cohort(3)CK_COHORT_PROTOTYPE(3)CK_COHORT_TRYLOCK_PROTOTYPE(3)CK_COHORT_INSTANCE(3)CK_COHORT_INITIALIZER(3)CK_COHORT_INIT(3)CK_COHORT_LOCK(3)CK_COHORT_UNLOCK(3)CK_COHORT_LOCKED(3)
more info lives at http://concurrencykit.org/ πΈ go read it, slay
okay that's the whole page bestie, and this one was dated March 9, 2013. with the manual name CK_COHORT_TRYLOCK(3) β vintage but still ate πβ¨ bye ily π¦
π¦ 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 2013 Brendon Scheinman
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms