提交 31552529 编写于 作者: P Paolo Bonzini 提交者: Anthony Liguori

notifier: switch to QLIST

Notifiers do not need to access both ends of the list, and using
a QLIST also simplifies the API.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 c77de088
...@@ -268,5 +268,5 @@ void qemu_add_mouse_mode_change_notifier(Notifier *notify) ...@@ -268,5 +268,5 @@ void qemu_add_mouse_mode_change_notifier(Notifier *notify)
void qemu_remove_mouse_mode_change_notifier(Notifier *notify) void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
{ {
notifier_list_remove(&mouse_mode_notifiers, notify); notifier_remove(notify);
} }
...@@ -335,7 +335,7 @@ void add_migration_state_change_notifier(Notifier *notify) ...@@ -335,7 +335,7 @@ void add_migration_state_change_notifier(Notifier *notify)
void remove_migration_state_change_notifier(Notifier *notify) void remove_migration_state_change_notifier(Notifier *notify)
{ {
notifier_list_remove(&migration_state_notifiers, notify); notifier_remove(notify);
} }
bool migration_is_active(MigrationState *s) bool migration_is_active(MigrationState *s)
......
...@@ -18,24 +18,24 @@ ...@@ -18,24 +18,24 @@
void notifier_list_init(NotifierList *list) void notifier_list_init(NotifierList *list)
{ {
QTAILQ_INIT(&list->notifiers); QLIST_INIT(&list->notifiers);
} }
void notifier_list_add(NotifierList *list, Notifier *notifier) void notifier_list_add(NotifierList *list, Notifier *notifier)
{ {
QTAILQ_INSERT_HEAD(&list->notifiers, notifier, node); QLIST_INSERT_HEAD(&list->notifiers, notifier, node);
} }
void notifier_list_remove(NotifierList *list, Notifier *notifier) void notifier_remove(Notifier *notifier)
{ {
QTAILQ_REMOVE(&list->notifiers, notifier, node); QLIST_REMOVE(notifier, node);
} }
void notifier_list_notify(NotifierList *list, void *data) void notifier_list_notify(NotifierList *list, void *data)
{ {
Notifier *notifier, *next; Notifier *notifier, *next;
QTAILQ_FOREACH_SAFE(notifier, &list->notifiers, node, next) { QLIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) {
notifier->notify(notifier, data); notifier->notify(notifier, data);
} }
} }
...@@ -21,22 +21,22 @@ typedef struct Notifier Notifier; ...@@ -21,22 +21,22 @@ typedef struct Notifier Notifier;
struct Notifier struct Notifier
{ {
void (*notify)(Notifier *notifier, void *data); void (*notify)(Notifier *notifier, void *data);
QTAILQ_ENTRY(Notifier) node; QLIST_ENTRY(Notifier) node;
}; };
typedef struct NotifierList typedef struct NotifierList
{ {
QTAILQ_HEAD(, Notifier) notifiers; QLIST_HEAD(, Notifier) notifiers;
} NotifierList; } NotifierList;
#define NOTIFIER_LIST_INITIALIZER(head) \ #define NOTIFIER_LIST_INITIALIZER(head) \
{ QTAILQ_HEAD_INITIALIZER((head).notifiers) } { QLIST_HEAD_INITIALIZER((head).notifiers) }
void notifier_list_init(NotifierList *list); void notifier_list_init(NotifierList *list);
void notifier_list_add(NotifierList *list, Notifier *notifier); void notifier_list_add(NotifierList *list, Notifier *notifier);
void notifier_list_remove(NotifierList *list, Notifier *notifier); void notifier_remove(Notifier *notifier);
void notifier_list_notify(NotifierList *list, void *data); void notifier_list_notify(NotifierList *list, void *data);
......
...@@ -453,7 +453,7 @@ void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier) ...@@ -453,7 +453,7 @@ void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier)
void qemu_unregister_clock_reset_notifier(QEMUClock *clock, Notifier *notifier) void qemu_unregister_clock_reset_notifier(QEMUClock *clock, Notifier *notifier)
{ {
notifier_list_remove(&clock->reset_notifiers, notifier); notifier_remove(notifier);
} }
void init_clocks(void) void init_clocks(void)
......
...@@ -2093,7 +2093,7 @@ void qemu_add_exit_notifier(Notifier *notify) ...@@ -2093,7 +2093,7 @@ void qemu_add_exit_notifier(Notifier *notify)
void qemu_remove_exit_notifier(Notifier *notify) void qemu_remove_exit_notifier(Notifier *notify)
{ {
notifier_list_remove(&exit_notifiers, notify); notifier_remove(notify);
} }
static void qemu_run_exit_notifiers(void) static void qemu_run_exit_notifiers(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册