notify.h 853 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifndef QEMU_NOTIFY_H
  14. #define QEMU_NOTIFY_H
  15. #include "qemu-queue.h"
  16. typedef struct Notifier Notifier;
  17. struct Notifier
  18. {
  19. void (*notify)(Notifier *notifier, void *data);
  20. QLIST_ENTRY(Notifier) node;
  21. };
  22. typedef struct NotifierList
  23. {
  24. QLIST_HEAD(, Notifier) notifiers;
  25. } NotifierList;
  26. #define NOTIFIER_LIST_INITIALIZER(head) \
  27. { QLIST_HEAD_INITIALIZER((head).notifiers) }
  28. void notifier_list_init(NotifierList *list);
  29. void notifier_list_add(NotifierList *list, Notifier *notifier);
  30. void notifier_remove(Notifier *notifier);
  31. void notifier_list_notify(NotifierList *list, void *data);
  32. #endif