2
0

notify.c 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. * Contributions after 2012-01-13 are licensed under the terms of the
  13. * GNU GPL, version 2 or (at your option) any later version.
  14. */
  15. #include "qemu-common.h"
  16. #include "notify.h"
  17. void notifier_list_init(NotifierList *list)
  18. {
  19. QLIST_INIT(&list->notifiers);
  20. }
  21. void notifier_list_add(NotifierList *list, Notifier *notifier)
  22. {
  23. QLIST_INSERT_HEAD(&list->notifiers, notifier, node);
  24. }
  25. void notifier_remove(Notifier *notifier)
  26. {
  27. QLIST_REMOVE(notifier, node);
  28. }
  29. void notifier_list_notify(NotifierList *list, void *data)
  30. {
  31. Notifier *notifier, *next;
  32. QLIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) {
  33. notifier->notify(notifier, data);
  34. }
  35. }