CK_PFLOCK(3)

✨ CK_PFLOCK ✨

okay so bestie, welcome to ck_pflock β€” it's a Concurrency Kit thing (that's libck, link it with -lck) and it's literally the centralized phase-fair reader-writer lock of your dreams. πŸŽ€


πŸ’… NAME πŸ’…

ck_pflock_init, ck_pflock_write_lock, ck_pflock_write_unlock, ck_pflock_read_lock, ck_pflock_read_unlock β€” centralized phase-fair reader-writer locks. no cap. πŸ‘‘


πŸ“š LIBRARY πŸ“š

Concurrency Kit (that's libck, and you link it with -lck, periodt).


🌸 SYNOPSIS 🌸

#include <ck_pflock.h>

ck_pflock_t lock = CK_PFLOCK_INITIALIZER;

void
ck_pflock_init(ck_pflock_t *lock);

void
ck_pflock_write_lock(ck_pflock_t *lock);

void
ck_pflock_write_unlock(ck_pflock_t *lock);

void
ck_pflock_read_lock(ck_pflock_t *lock);

void
ck_pflock_read_unlock(ck_pflock_t *lock);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the vibe: this is a centralized phase-fair reader-writer lock. it's giving low maintenance because it needs very little space overhead, and it's also giving speed because it has a low latency fast path. iconic behavior honestly. ✨


🌈 EXAMPLE 🌈

#include <ck_pflock.h>

static ck_pflock_t lock = CK_TFLOCK_INITIALIZER;

static void
reader(void)
{

        for (;;) {
                ck_pflock_read_lock(&lock);
                /* Read-side critical section. */
                ck_pflock_read_unlock(&lock);
        }

        return;
}

static void
writer(void)
{

        for (;;) {
                ck_pflock_write_lock(&lock);
                /* Write-side critical section. */
                ck_pflock_write_unlock(&lock);
        }

        return;
}

πŸ‘€ SEE ALSO πŸ‘€

more info lives at http://concurrencykit.org/ if you wanna go read up, bestie 🫢


that's the whole page fr fr. this one's from April 22, 2014, and it's the ck_pflock(3) page πŸ’– slay, go lock something responsibly 🌸

πŸ“¦ where this page comes from