Other Alias
sd_event_source_set_priority, SD_EVENT_PRIORITY_IMPORTANT, SD_EVENT_PRIORITY_NORMAL, SD_EVENT_PRIORITY_IDLESYNOPSIS
#include <systemd/sd-event.h>
enum { SD_EVENT_SOURCE_IMPORTANT = -100, SD_EVENT_SOURCE_NORMAL = 0, SD_EVENT_SOURCE_IDLE = 100, };
-
int sd_event_source_set_priority(sd_event_source *source, int64_t priority);
- int sd_event_source_get_priority(sd_event_source *source, int64_t *priority);
DESCRIPTION
sd_event_source_set_priority()
Priorities define the order in which event sources that have seen events are dispatched. Care should be taken to ensure that high-priority event sources (those with negative priority values assigned) do not cause starvation of low-priority event sources (those with positive priority values assigned).
The order in which event sources with the same priority are dispatched is undefined, but the event loop generally tries to dispatch them in the order it learnt about events on them. As the backing kernel primitives do not provide accurate information about the order in which events occurred this is not necessarily reliable. However, it is guaranteed that if events are seen on multiple same-priority event sources at the same time, each one is not dispatched again until all others have been dispatched once. This behaviour guarantees that within each priority particular event sources do not starve or dominate the event loop.
sd_event_source_get_priority() may be used to query the current priority assigned to the event source object source.
RETURN VALUE
On success, sd_event_source_set_priority() and sd_event_source_get_priority() return a non-negative integer. On failure, they return a negative errno-style error code.
ERRORS
Returned errors may indicate the following problems:
-EINVAL
- source is not a valid pointer to an sd_event_source object.
-ENOMEM
- Not enough memory.
-ESTALE
- The event loop is already terminated.
-ECHILD
- The event loop has been created in a different process.
NOTES
These APIs are implemented as a shared library, which can be compiled and linked to with the libsystemd pkg-config(1) file.