SD_EVENT_...ET_PENDING(3)

πŸ’… NAME πŸ’…

ok so like β€” sd_event_source_get_pending β€” it's the little function that tells you whether your event source is pending or not, bestie. That's literally it, that's the whole vibe check ✨


🌸 SYNOPSIS 🌸

#include <systemd/sd-event.h>

int sd_event_source_get_pending(sd_event_source *source);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: sd_event_source_get_pending() is your new fave little detective πŸ” β€” you hand it the event source object you passed as source, and it tells you whether that source has, like, seen events but hasn't been dispatched yet. Which means it's marked "pending" πŸ’… that's the word, that's the whole thing.

So when do things start pending? Ngl, event source objects are not pending when they're first born, like when you create them with calls such as sd_event_add_io(3), sd_event_add_time(3) β€” except:

  • the ones you make with sd_event_add_defer(3)? yeah those are immediately marked pending, no waiting around, main character energy πŸ‘‘
  • and sd_event_add_exit(3)? for that one the whole "pending" concept is literally not defined πŸ™ˆ like it's just not a thing there

For the full deets, go read the respective manual pages, iykyk.

Here's the cute part πŸŽ€ β€” in each event loop iteration, one event source out of all the pending ones gets dispatched. Just one. And the order? That's defined by the event source priority, as set with sd_event_source_set_priority(3) ⭐

And a lil bonus for I/O event sources (the ones from sd_event_add_io(3)): you can call sd_event_source_get_io_revents(3) to query the type of event that's pending in more detail. Obsessed with the extra detail honestly 🫢


πŸ”₯ RETURN VALUE πŸ”₯

On success, sd_event_source_get_pending() returns an integer greater than zero when the event source is marked pending, and zero when it's not marked pending. On failure? negative errno-style error code, tragic 😭

πŸ’€ Errors

Returned errors may indicate the following problems:

  • -EINVAL β€” source is not a valid pointer to an sd_event_source object. like, that's not a real pointer bestie 🚩
  • -EDOM β€” source refers to an event source object created with sd_event_add_exit(3). we talked about this, pending isn't defined there βœ‹
  • -ENOMEM β€” Not enough memory. ran out of vibes (and RAM) πŸ˜”
  • -ESTALE β€” The event loop is already terminated. it's over, it's done, it's giving ghost town πŸ‘»
  • -ECHILD β€” The event loop has been created in a different process, library or module instance. not your child, can't touch it πŸ™…

⭐ NOTES ⭐

The functions described here are available as a shared library, which you can compile against and link to with the libsystemd pkg-config(1) file. slay πŸ”₯

All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. And multiple independent objects may be used from different threads in parallel. so like, share objects responsibly πŸ’–

⚠️ heads up bestie β€” the code described here uses getenv(3), which is declared to be not multi-thread-safe. That means the code calling the functions described here must not call setenv(3) from a parallel thread. The recommendation is to only do calls to setenv() from an early phase of the program when no other threads have been started. early-phase setenv or it's chaos, no cap 🧚

🌈 HISTORY 🌈

sd_event_source_get_pending() was added in version 229. a classic, an icon, a legend πŸ’œ


πŸ“ SEE ALSO πŸ“


okay that's the whole page, go forth and check your pending states πŸ’…βœ¨ this lil masterpiece is from systemd 261.3, and yeah the page name is the very chaotic SD_EVENT_...ET_PENDING(3) β€” mwah, bye bestie πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from