QB_THREAD_LOCK_CREATE(3)

πŸ’… QB_THREAD_LOCK_CREATE β€” bestie edition

okay so this page is QB_THREAD_LOCK_CREATE(3) from the libqb Programmer's Manual, and we're gonna make a lock. a whole new lock. of a type you pick. let's go πŸŽ€


✨ NAME ✨

qb_thread_lock_create β€” Create a new lock of the given type.

like that's literally it. that's the whole job. she creates locks πŸ’–


🌸 SYNOPSIS 🌸

#include <qb/qbutil.h>

qb_thread_lock_t * qb_thread_lock_create(
    /*
     * QB_THREAD_LOCK_SHORT == spinlock (where available, else mutex)
     * QB_THREAD_LOCK_LONG == mutex
     */
    qb_thread_lock_type_t  type
);

no cap, that's the whole call. you hand her a type and she hands you back a lock. periodt ✨


πŸ¦‹ PARAMS πŸ¦‹

  • type β€” the vibe of lock you want, bestie:
    • QB_THREAD_LOCK_SHORT == spinlock (where available, else mutex)
    • QB_THREAD_LOCK_LONG == mutex

so short = spinny if your system's got it, otherwise she just falls back to a mutex, no drama. long = mutex, always, every time πŸ’œ


πŸ’– DESCRIPTION πŸ’–

hmm okay so this section is literally just here being a heading, there's no prose under it in the original. iconic of her honestly, she said "the title speaks for itself" πŸ’…

the tea is: you call qb_thread_lock_create, you tell her which type you want from the params up there, and she spins you up a fresh lock. that's the whole storyline. main character energy only 🌈


πŸ‘‘ STRUCTURES πŸ‘‘

the enum you're pulling type from, in all her glory:

enum qb_thread_lock_type_t {
      QB_THREAD_LOCK_SHORT;
      QB_THREAD_LOCK_LONG;
};

two options. two moods. pick your fighter ⭐


🌟 RETURN VALUE 🌟

pointer to qb_thread_lock_type_t or NULL on error.

🫢 bestie if you get NULL back, something went sideways β€” that's your sign to check yourself before you wreck yourself. do NOT go dereferencing that. no cap 😭

πŸ”₯ SEE ALSO πŸ”₯

the whole friend group, all of them, every single one, we don't leave anybody out:

qb_util_nano_current_get(3), qb_util_stopwatch_stop(3), qb_util_stopwatch_split(3), qb_util_stopwatch_split_ctl(3), qb_thread_unlock(3), qb_strerror_r(3), qb_util_stopwatch_time_split_get(3), qb_util_set_log_function(3), qb_util_timespec_from_epoch_get(3), qb_thread_lock_destroy(3), qb_thread_trylock(3), qb_util_nano_monotonic_hz(3), qb_util_nano_from_epoch_get(3), qb_util_stopwatch_create(3), qb_util_stopwatch_split_last(3), qb_thread_lock(3), qb_util_stopwatch_free(3), qb_timespec_add_ms(3), qb_util_stopwatch_start(3), qb_util_stopwatch_us_elapsed_get(3), qb_util_stopwatch_sec_elapsed_get(3)

go read them. or don't. i'm not your mom, i'm just your bestie who knows things 🧚


Copyright (C) 2010-2020 Red Hat, Inc.


and that's the page babes πŸŽ€ big kisses from the libqb girlies β€” this one's dated 2025-09-16, so it's fresh, it's cute, it's giving documentation πŸ’– bye bestie, go lock something πŸ¦‹βœ¨

πŸ“¦ where this page comes from