CK_COHORT_PROTOTYPE(3)

πŸ’… CK_COHORT_PROTOTYPE β€” bestie's guide to defining a cohort type (3)

okay so like. you're in ck_cohort land. hi. welcome. 🫢

πŸ“š LIBRARY

Concurrency Kit (libck, -lck) β€” yes girl, link it.


✨ SYNOPSIS ✨

#include <ck_cohort.h>

CK_COHORT_PROTOTYPE(COHORT_NAME cohort_name, TYPE global_lock_method,
    LOCK_FXN global_unlock_method, LOCK_FXN local_lock_method,
    LOCK_FXN local_unlock_method);

🌸 DESCRIPTION 🌸

here's the tea, bestie: ck_cohort.h ships with absolutely zero cohort types defined. not one. empty. the header is giving "i'm just a template, do it yourself" energy. 😭

so you β€” the main character β€” have to define whatever types you want using the CK_COHORT_PROTOTYPE or CK_COHORT_TRYLOCK_PROTOTYPE(3) macros. and heads up: if you want your cohort type to support trylock operations, you have to use CK_COHORT_TRYLOCK_PROTOTYPE. CK_COHORT_PROTOTYPE is not the one for that, no cap. πŸ’€

the CK_COHORT_PROTOTYPE macro eats the following arguments:

  • cohort_name β€” an identifier for this cohort type. this is the name you'll be passing to literally every other CK_COHORT macro, so remember it. it's the moment, it's the brand, it's the whole identity. πŸ‘‘
  • global_lock_method β€” the method that should be called to acquire the global lock πŸ”₯
  • global_unlock_method β€” the method that should be called to relinquish the global lock
  • 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

and once you've defined your lil type? you declare instances of it like this:

CK_COHORT_INSTANCE(cohort_name) cohort;

look at you. iconic. defining types. slaying. πŸŽ€


πŸ‘€ SEE ALSO

go read these next, bestie, they're all part of the saga:

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


mwah πŸ’‹ that's the whole page. courtesy of Concurrency Kit (libck, -lck), dated February 24, 2013 β€” yes it's an old queen but she still eats. go lock something (safely). periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from