throttle: introduce enum ThrottleDirection

Use enum ThrottleDirection instead of number index.

Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Message-Id: <20230728022006.1098509-2-pizhenwei@bytedance.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
This commit is contained in:
zhenwei pi
2023-07-28 10:19:58 +08:00
committed by Hanna Czenczek
parent f5fe7c17ac
commit 8ba02c24ea
2 changed files with 17 additions and 10 deletions

View File

@ -99,13 +99,18 @@ typedef struct ThrottleState {
int64_t previous_leak; /* timestamp of the last leak done */
} ThrottleState;
typedef enum {
THROTTLE_READ = 0,
THROTTLE_WRITE,
THROTTLE_MAX
} ThrottleDirection;
typedef struct ThrottleTimers {
QEMUTimer *timers[2]; /* timers used to do the throttling */
QEMUTimer *timers[THROTTLE_MAX]; /* timers used to do the throttling */
QEMUClockType clock_type; /* the clock used */
/* Callbacks */
QEMUTimerCB *read_timer_cb;
QEMUTimerCB *write_timer_cb;
QEMUTimerCB *timer_cb[THROTTLE_MAX];
void *timer_opaque;
} ThrottleTimers;