]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/ratelimit.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
8 typedef struct RateLimit
{
9 usec_t interval
; /* Keep those two fields first so they can be initialized easily: */
10 unsigned burst
; /* RateLimit rl = { INTERVAL, BURST }; */
15 #define RATELIMIT_OFF (const RateLimit) { .interval = USEC_INFINITY, .burst = UINT_MAX }
17 static inline void ratelimit_reset(RateLimit
*rl
) {
18 rl
->num
= rl
->begin
= 0;
21 static inline bool ratelimit_configured(RateLimit
*rl
) {
22 return rl
->interval
> 0 && rl
->burst
> 0;
25 bool ratelimit_below(RateLimit
*r
);
27 unsigned ratelimit_num_dropped(RateLimit
*r
);
29 usec_t
ratelimit_end(const RateLimit
*rl
);
30 usec_t
ratelimit_left(const RateLimit
*rl
);