int sd_event_source_set_ratelimit(sd_event_source *source, uint64_t interval_usec, unsigned burst);
int sd_event_source_get_ratelimit(sd_event_source *source, uint64_t* ret_interval_usec, unsigned* ret_burst);
int sd_event_source_is_ratelimited(sd_event_source *source);
Pass the event source to operate on as first argument, a time interval in microseconds as second argument and a maximum dispatch limit ("burst") as third parameter. Whenever the event source is dispatched more often than the specified burst within the specified interval it is placed in a mode similar to being disabled with sd_event_source_set_enabled(3) and the SD_EVENT_OFF parameter. However it is disabled only temporarily – once the specified interval is over regular operation resumes. It is again disabled temporarily once the specified rate limiting is hit the next time. If either the interval or the burst value are specified as zero, rate limiting is turned off. By default event sources do not have rate limiting enabled. Note that rate limiting and disabling via sd_event_source_set_enabled() are independent of each other, and an event source will only effect event loop wake-ups and is dispatched while it both is enabled and rate limiting is not in effect.
sd_event_source_get_ratelimit() may be used to query the current rate limiting parameters set on the event source object source. The previously set interval and burst vales are returned in the second and third argument.
sd_event_source_is_ratelimited() may be used to query whether the event source is currently affected by rate limiting, i.e. it has recently hit the rate limit and is currently temporarily disabled due to that.
Rate limiting is currently implemented for I/O, timer, signal, defer and inotify event sources.