CK_COHORT_TRYLOCK_PROTOTYPE(3)
π NAME π
CK_COHORT_TRYLOCK_PROTOTYPE β bestie, this is the macro that lets you define your very own cohort type with specified lock types, and it comes with trylock energy baked in. β¨
π LIBRARY π
Concurrency Kit β that's libck, and you link it with -lck. π«Ά
β¨ SYNOPSIS β¨
#include <ck_cohort.h>
CK_COHORT_TRYLOCK_PROTOTYPE(COHORT_NAME cohort_name,
LOCK_FXN global_lock_method, LOCK_FXN global_unlock_method,
BOOL_LOCK_FXN global_locked_method,
BOOL_LOCK_FXN global_trylock_method, LOCK_FXN local_lock_method,
LOCK_FXN local_unlock_method, BOOL_LOCK_FXN local_locked_method,
BOOL_LOCK_FXN local_trylock_method);
π¦ DESCRIPTION π¦
Okay so here's the tea: ck_cohort.h does not define any cohort types for you. Not a single one. It's giving "you're the main character, you build it." π
Instead, you β yes you, bestie β have to use the CK_COHORT_PROTOTYPE or CK_COHORT_TRYLOCK_PROTOTYPE macros to define whatever types you wanna use. And you specifically reach for CK_COHORT_TRYLOCK_PROTOTYPE when you want your cohort type to have support for trylock operations. No cap.
So CK_COHORT_TRYLOCK_PROTOTYPE takes these arguments, and yes, we're going through every single one because they all matter:
cohort_nameβ the identifier for this cohort type. You're gonna have to pass this bad boy to every otherCK_COHORTmacro, so remember its name like it's your bestie's birthday. πglobal_lock_methodβ the method that should be called to acquire the global lock. Grabby hands. πglobal_unlock_methodβ the method that should be called to relinquish the global lock. Let it gooo. ποΈglobal_locked_methodβ this method should return true iff the global lock is acquired by a thread. Simple as that.global_trylock_methodβ the method that should be called to try to acquire the global lock. Key detail: it should not block, and it returns true iff the lock was successfully acquired. It's the "hey are you free? no? cool cool cool" of locking. πlocal_lock_methodβ the method that should be called to acquire the local lock. πlocal_unlock_methodβ the method that should be called to relinquish the local lock. Bye boo. πglobal_locked_methodβ this method should return true iff the global lock is acquired by a thread. (Yes, it literally saysglobal_locked_methodagain right here in the source, I'm just the messenger, reporting the lore exactly as it was handed to me. π)local_trylock_methodβ the method that should be called to try to acquire the local lock. Same rules as the global one: it should not block, and it returns true iff the lock was successfully acquired. π₯
πΈ Declaring an instance πΈ
Once you've defined your type, instances of the defined cohort type can be declared like this:
CK_COHORT_INSTANCE(cohort_name) cohort;
Look at that. Gorgeous. Iconic. Slay. π
π SEE ALSO π
Go read these next, bestie, they're all in the fam:
ck_cohort(3)CK_COHORT_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)CK_COHORT_TRYLOCK(3)
Additional information available at http://concurrencykit.org/ β go be nosy, you deserve it. π
And that's the whole page, bestie! This one's from the <strong>Concurrency Kit (libck)</strong> era, dated <strong>March 9, 2013.</strong>, and it's filed under <strong>CK_COHORT_TRYLOCK_PROTOTYPE(3)</strong>. Periodt. π
β¨
π¦ 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