hw/block/nvme: pull write pointer advancement to separate function
[qemu/rayw.git] / include / qemu / notify.h
blobbcfa70fb2edffb319fe87de69209af23c380d048
1 /*
2 * Notifier lists
4 * Copyright IBM, Corp. 2010
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef QEMU_NOTIFY_H
15 #define QEMU_NOTIFY_H
17 #include "qemu/queue.h"
19 typedef struct Notifier Notifier;
21 struct Notifier
23 void (*notify)(Notifier *notifier, void *data);
24 QLIST_ENTRY(Notifier) node;
27 typedef struct NotifierList
29 QLIST_HEAD(, Notifier) notifiers;
30 } NotifierList;
32 #define NOTIFIER_LIST_INITIALIZER(head) \
33 { QLIST_HEAD_INITIALIZER((head).notifiers) }
35 void notifier_list_init(NotifierList *list);
37 void notifier_list_add(NotifierList *list, Notifier *notifier);
39 void notifier_remove(Notifier *notifier);
41 void notifier_list_notify(NotifierList *list, void *data);
43 bool notifier_list_empty(NotifierList *list);
45 /* Same as Notifier but allows .notify() to return errors */
46 typedef struct NotifierWithReturn NotifierWithReturn;
48 struct NotifierWithReturn {
49 /**
50 * Return 0 on success (next notifier will be invoked), otherwise
51 * notifier_with_return_list_notify() will stop and return the value.
53 int (*notify)(NotifierWithReturn *notifier, void *data);
54 QLIST_ENTRY(NotifierWithReturn) node;
57 typedef struct NotifierWithReturnList {
58 QLIST_HEAD(, NotifierWithReturn) notifiers;
59 } NotifierWithReturnList;
61 #define NOTIFIER_WITH_RETURN_LIST_INITIALIZER(head) \
62 { QLIST_HEAD_INITIALIZER((head).notifiers) }
64 void notifier_with_return_list_init(NotifierWithReturnList *list);
66 void notifier_with_return_list_add(NotifierWithReturnList *list,
67 NotifierWithReturn *notifier);
69 void notifier_with_return_remove(NotifierWithReturn *notifier);
71 int notifier_with_return_list_notify(NotifierWithReturnList *list,
72 void *data);
74 #endif