rte_ticketlock.h(3)

πŸ’– rte_ticketlock.h β€” the library functions manual page, but make it cute ✨

okay so bestie, we're in rte_ticketlock.h(3) territory, living under the Library Functions Manual umbrella, and this is literally the page where DPDK keeps its ticket locks. grab a snack, we're doing this πŸ“


🌸 NAME 🌸

rte_ticketlock.h β€” that's it, that's the name, she's self-titled and she knows it πŸ’…


✨ SYNOPSIS ✨

first things first, you gotta pull in the girlies:

#include <rte_common.h>
#include <rte_lcore.h>
#include <rte_pause.h>
#include <rte_stdatomic.h>

πŸŽ€ Data Structures

  • union rte_ticketlock_t β€” the moment, the icon

πŸ¦‹ Macros

  • #define RTE_TICKETLOCK_INITIALIZER { 0 }
  • #define TICKET_LOCK_INVALID_ID -1
  • #define RTE_TICKETLOCK_RECURSIVE_INITIALIZER

πŸ’œ Functions

  • static void rte_ticketlock_init (rte_ticketlock_t *tl)
  • static void rte_ticketlock_lock (rte_ticketlock_t *tl)
  • static void rte_ticketlock_unlock (rte_ticketlock_t *tl)
  • static int rte_ticketlock_trylock (rte_ticketlock_t *tl)
  • static int rte_ticketlock_is_locked (rte_ticketlock_t *tl)
  • static void rte_ticketlock_recursive_init (rte_ticketlock_recursive_t *tlr)
  • static void rte_ticketlock_recursive_lock (rte_ticketlock_recursive_t *tlr)
  • static void rte_ticketlock_recursive_unlock (rte_ticketlock_recursive_t *tlr)
  • static int rte_ticketlock_recursive_trylock (rte_ticketlock_recursive_t *tlr)

🌈 Detailed Description 🌈

RTE ticket locks β€” no cap, this file defines an API for ticket locks, and the whole system is giving deli counter energy: every waiting thread gets a ticket, and they take the lock one by one, first come, first serviced. It's fair, it's orderly, it's the main character of synchronization primitives πŸ‘‘

🚨 not me being serious for one sec: all locks must be initialised before use, and only initialised once. that's non-negotiable bestie, do NOT double-init her.

Definition in file rte_ticketlock.h.


🧚 Macro Definition Documentation 🧚

#define RTE_TICKETLOCK_INITIALIZER { 0 }

a static ticketlock initializer. so clean, so simple, zero drama ✨

Definition at line 43 of file rte_ticketlock.h.

#define TICKET_LOCK_INVALID_ID -1

the rte_ticketlock_recursive_t type. yes she said -1, the invalid ID, the "nobody's home" ticket πŸ™ˆ

Definition at line 128 of file rte_ticketlock.h.

#define RTE_TICKETLOCK_RECURSIVE_INITIALIZER

Value:

{RTE_TICKETLOCK_INITIALIZER, \
TICKET_LOCK_INVALID_ID, 0}

a static recursive ticketlock initializer. it's the stacked version, she contains multitudes πŸ’…

Definition at line 139 of file rte_ticketlock.h.


πŸ”₯ Function Documentation πŸ”₯

void rte_ticketlock_init (rte_ticketlock_t * tl) [inline], [static]

Initialize the ticketlock to an unlocked state. fresh start, glowing skin, unlocked ✨

Parameters

  • tl β€” a pointer to the ticketlock.

Definition at line 52 of file rte_ticketlock.h.

void rte_ticketlock_lock (rte_ticketlock_t * tl) [inline], [static]

Take the ticketlock. your ticket's up, step to the counter queen πŸ‘‘

Parameters

  • tl β€” a pointer to the ticketlock.

Definition at line 64 of file rte_ticketlock.h.

void rte_ticketlock_unlock (rte_ticketlock_t * tl) [inline], [static]

Release the ticketlock. hand it back, be polite, let the next girl go 🫢

Parameters

  • tl β€” a pointer to the ticketlock.

Definition at line 78 of file rte_ticketlock.h.

int rte_ticketlock_trylock (rte_ticketlock_t * tl) [inline], [static]

Try to take the lock. lowkey a "do you want me or not" situation, and she'll tell you immediately, no waiting around πŸ’€

Parameters

  • tl β€” a pointer to the ticketlock.

Returns

  • 1 if the lock is successfully taken; 0 otherwise.

Definition at line 93 of file rte_ticketlock.h.

int rte_ticketlock_is_locked (rte_ticketlock_t * tl) [inline], [static]

Test if the lock is taken. vibe check, but for locks πŸ”

Parameters

  • tl β€” a pointer to the ticketlock.

Returns

  • 1 if the lock is currently taken; 0 otherwise.

Definition at line 118 of file rte_ticketlock.h.

void rte_ticketlock_recursive_init (rte_ticketlock_recursive_t * tlr) [inline], [static]

Initialize the recursive ticketlock to an unlocked state. same energy, but now she's recursive πŸŒ€

Parameters

  • tlr β€” a pointer to the recursive ticketlock.

Definition at line 149 of file rte_ticketlock.h.

void rte_ticketlock_recursive_lock (rte_ticketlock_recursive_t * tlr) [inline], [static]

Take the recursive ticketlock. she can hold herself and also herself, it's iconic 🌸

Parameters

  • tlr β€” a pointer to the recursive ticketlock.

Definition at line 163 of file rte_ticketlock.h.

void rte_ticketlock_recursive_unlock (rte_ticketlock_recursive_t * tlr) [inline], [static]

Release the recursive ticketlock. unwinding the whole stack, gracefully πŸ’–

Parameters

  • tlr β€” a pointer to the recursive ticketlock.

Definition at line 181 of file rte_ticketlock.h.

int rte_ticketlock_recursive_trylock (rte_ticketlock_recursive_t * tlr) [inline], [static]

Try to take the recursive lock. the "hey bestie, are you free" of it all ✨

Parameters

  • tlr β€” a pointer to the recursive ticketlock.

Returns

  • 1 if the lock is successfully taken; 0 otherwise.

Definition at line 199 of file rte_ticketlock.h.


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for DPDK from the source code. not a human author, just a robot doing her thing πŸ’…


okay so that's literally the whole page, and to close it out: this came to you courtesy of DPDK, Version 25.11.3, dated right alongside rte_ticketlock.h(3). slay, go lock something (responsibly, after initialising it, exactly once) πŸ¦‹πŸ’œ periodt

πŸ“¦ where this page comes from