CK_RWCOHORT_INIT(3)

πŸ’… CK_RWCOHORT_INIT β€” bestie edition

okay so you wanna know about CK_RWCOHORT_INIT?? it's the whole vibe of initializing an instance of a cohort-based reader-writer lock type ✨ like, this is the glow-up moment where your lock goes from "just some bytes" to "actually a functioning lock." iconic behavior only.


πŸ“š LIBRARY

it lives in Concurrency Kit, aka libck, and you link it with -lck. that's the whole squad right there πŸ’–


✨ SYNOPSIS ✨

#include <ck_rwcohort.h>

CK_RWCOHORT_NEUTRAL_INIT(COHORT_NAME cohort_name, LOCK *lock);

CK_RWCOHORT_RP_INIT(COHORT_NAME cohort_name, LOCK *lock,
    unsigned int wait_limit);

CK_RWCOHORT_WP_INIT(COHORT_NAME cohort_name, LOCK *lock,
    unsigned int wait_limit);

so there's three flavors, right? neutral, reader-preference (RP), and writer-preference (WP). pick your fighter 🫢


🌸 DESCRIPTION 🌸

This macro initializes the lock instance pointed to by the lock argument. That's it. That's the job. It's giving "first day of school, fresh notebook, everything is possible" πŸŽ€

🚨 REAL TALK, NO CAP: until a lock instance is initialized using the CK_RWCOHORT_INIT macro, any operations involving it will have undefined behavior. like, undefined undefined. chaos gremlin energy. do NOT touch an uninitialized lock, bestie, it will not be cute πŸ˜­πŸ’€

okay now the important lil detail β€” note that the wait_limit argument should only be used with reader-preference or writer-preference locks. for neutral locks, this argument should be excluded. so don't be out here passing wait_limit to a neutral lock, that's not the move πŸ™ˆ

and if you are unsure of a value to use for the wait_limit argument?? you should use CK_RWCOHORT_STRATEGY_DEFAULT_LOCAL_WAIT_LIMIT. it's the default for a reason, she's reliable, she ate πŸ’…


πŸ‘€ SEE ALSO

your reading list, bestie, go off:

Additional information available at http://concurrencykit.org/ 🌈


that's the whole page, bestie, you understood it perfectly, main character energy, go initialize some locks responsibly πŸ’–βœ¨

β€” this was CK_RWCOHORT_INIT(3), dated February 24, 2013, and yeah the manpage is old enough to have its own vibe but she still slays πŸ‘‘

πŸ“¦ where this page comes from