2
0

notify.c 832 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Notifier lists
  3. *
  4. * Copyright IBM, Corp. 2010
  5. *
  6. * Authors:
  7. * Anthony Liguori <aliguori@us.ibm.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2. See
  10. * the COPYING file in the top-level directory.
  11. *
  12. */
  13. #include "qemu-common.h"
  14. #include "notify.h"
  15. void notifier_list_init(NotifierList *list)
  16. {
  17. QTAILQ_INIT(&list->notifiers);
  18. }
  19. void notifier_list_add(NotifierList *list, Notifier *notifier)
  20. {
  21. QTAILQ_INSERT_HEAD(&list->notifiers, notifier, node);
  22. }
  23. void notifier_list_remove(NotifierList *list, Notifier *notifier)
  24. {
  25. QTAILQ_REMOVE(&list->notifiers, notifier, node);
  26. }
  27. void notifier_list_notify(NotifierList *list, void *data)
  28. {
  29. Notifier *notifier, *next;
  30. QTAILQ_FOREACH_SAFE(notifier, &list->notifiers, node, next) {
  31. notifier->notify(notifier, data);
  32. }
  33. }