CK_COHORT_LOCK(3)

πŸ’– CK_COHORT_LOCK(3) β€” bestie, it's time to grab the cohort lock πŸ’–

okay so real talk, this page is from the Concurrency Kit manual, and yeah, it lives in section 3 of the manual. grab a snack, we're learning locks πŸ“


✨ LIBRARY ✨

Concurrency Kit (that's libck, link it with -lck) πŸŽ€


🌸 SYNOPSIS 🌸

#include <ck_cohort.h>

CK_COHORT_LOCK(COHORT_NAME cohort_name, COHORT *cohort,
    void *global_context, void *local_context);

like, that's the whole vibe. two contexts, one cohort, zero chill πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

So this call? It attempts to acquire both the local and global locks from cohort β€” global only if necessary, bestie, it's not out here doing extra work for no reason ✨

And because this is a locking call, it will block until both locks have been acquired. no cap. it just sits there, patiently, waiting for its moment. main character energy fr fr 🫢

Now the contexts β€” here's the tea β˜•:

  • global_context gets passed as the second argument to the function that was provided as the global_lock_method argument to CK_COHORT_PROTOTYPE, if that method is called. (emphasis on if, she's conditional πŸ’…)
  • local_context gets passed to the function specified by local_lock_method.

that's it. that's the whole function. iconic behavior honestly πŸ‘‘

⚠️ heads up bestie: this one blocks. if you can't handle the wait, that's literally what CK_COHORT_TRYLOCK(3) is for. iykyk πŸ¦‹

πŸ”₯ SEE ALSO πŸ”₯

go read the whole family, they're all so good:

and if you want even more, there's always http://concurrencykit.org/ 🌈 β€” she's got everything, periodt.


mwah πŸ’‹ that's a wrap, bestie β€” this page is dated February 24, 2013, it's the CK_COHORT_LOCK(3) page from the Concurrency Kit manual, and you absolutely ate this reading session. go forth and lock responsibly πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from