rte_alarm.h(3)

πŸ’– rte_alarm.h(3) β€” the alarm-clock page bestie πŸ’–

okay so this is the manual page for rte_alarm.h, a header from DPDK, and it's literally just alarm stuff. no hpet required, no drama, just vibes and callbacks. let's get into it πŸŽ€


✨ NAME ✨

rte_alarm.h β€” the header that gives you alarms. that's it, that's the name. short, sweet, icon behavior.


🌈 SYNOPSIS 🌸

#include <stdint.h>

πŸ¦‹ Typedefs

  • typedef void(* rte_eal_alarm_callback) (void *arg) β€” the callback type, aka the function signature your alarm calls when it goes off.

🫢 Functions

int rte_eal_alarm_set (uint64_t us, rte_eal_alarm_callback cb, void *cb_arg)
int rte_eal_alarm_cancel (rte_eal_alarm_callback cb_fn, void *cb_arg)

πŸ’… Detailed Description πŸ’…

alarm functions!! πŸ’–

this is the simple alarm-clock functionality supplied by eal. key detail: it does not require hpet support β€” so you're free, you're unbothered, you don't need that particular hardware feature. periodt.

Definition in file rte_alarm.h.


πŸŽ€ Typedef Documentation πŸŽ€

⭐ typedef void(* rte_eal_alarm_callback) (void *arg)

this is the signature of the callback function that gets called when an alarm goes off. like, that's the whole job. when the alarm pops, this is what runs. lowkey iconic.

Definition at line 26 of file rte_alarm.h.


πŸ”₯ Function Documentation πŸ”₯

πŸ’œ int rte_eal_alarm_set (uint64_t us, rte_eal_alarm_callback cb, void *cb_arg)

bestie this is the function that sets a callback to be triggered once us microseconds have expired. ⏰

important timing tea, so listen up: the accuracy of timing to the microsecond is not guaranteed. the alarm function will not be called before the requested time, but it may be called a short period of time afterwards. so don't come for it if it's a lil late, it was never gonna be early. πŸ™ˆ

also, the alarm handler will be called only once. one and done, no repeats.

and the nice part: there is no need to call "rte_eal_alarm_cancel" from within the callback function. so don't stress about cleanup in there.

🌸 Parameters

  • us β€” The time in microseconds before the callback is called
  • cb β€” The function to be called when the alarm expires
  • cb_arg β€” Pointer parameter to be passed to the callback function

✨ Returns

  • On success, zero. On failure, a negative error number.

πŸ’€ int rte_eal_alarm_cancel (rte_eal_alarm_callback cb_fn, void * cb_arg)

this one cancels an alarm callback that has been registered before. say sike right now πŸ’…

one lil note: if used outside alarm callback it waits for all callbacks to finish execution. so it's giving patient, but also it will sit there until everything's done. no cap.

🧚 Parameters

  • cb_fn β€” alarm callback
  • cb_arg β€” Pointer parameter to be passed to the callback function. To remove all copies of a given callback function, irrespective of parameter, (void *)-1 can be used here. yes, (void *)-1, that's the magic wildcard bestie, write it exactly like that.

πŸ‘‘ Returns

okay this one has a whole menu of return situations, so pay attention, this is the main character energy part:

  • value greater than 0 and rte_errno not changed β€” returned value is the number of canceled alarm callback functions
  • value greater or equal 0 and rte_errno set to EINPROGRESS β€” at least one alarm could not be canceled because cancellation was requested from alarm callback context. Returned value is the number of successfully canceled alarm callbacks
  • 0 and rte_errno set to ENOENT β€” no alarm found
  • -1 and rte_errno set to EINVAL β€” invalid parameter (NULL callback)
🚨 not me reminding you that a NULL callback is a no-go and gets you EINVAL with a -1. read the return list, memorize the return list, live by the return list. fr fr.

πŸ’– Author πŸ’–

Generated automatically by Doxygen for DPDK from the source code. so nobody hand-wrote this lil cutie, the robot did it and honestly it ate. πŸ€–βœ¨


so yeah that's the whole page β€” alarm set, alarm cancel, one-shot callbacks, microseconds that are approximate-but-never-early, and a return-value lore drop at the end. you're basically a timing expert now, bestie, slay πŸ¦‹

this was DPDK Version 25.11.3, page rte_alarm.h(3) β€” mwah, go forth and schedule responsibly πŸ’…πŸŒΈ

πŸ“¦ where this page comes from