blob: 03cf26c0b62352670598970d7e2a8f385280de87 [file] [log] [blame]
Anthony Liguorid1e70c52010-03-09 13:16:14 -06001/*
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
14#ifndef QEMU_NOTIFY_H
15#define QEMU_NOTIFY_H
16
17#include "qemu-queue.h"
18
19typedef struct Notifier Notifier;
20
21struct Notifier
22{
Jan Kiszka9e8dd452011-06-20 14:06:26 +020023 void (*notify)(Notifier *notifier, void *data);
Paolo Bonzini31552522012-01-13 17:34:01 +010024 QLIST_ENTRY(Notifier) node;
Anthony Liguorid1e70c52010-03-09 13:16:14 -060025};
26
27typedef struct NotifierList
28{
Paolo Bonzini31552522012-01-13 17:34:01 +010029 QLIST_HEAD(, Notifier) notifiers;
Anthony Liguorid1e70c52010-03-09 13:16:14 -060030} NotifierList;
31
32#define NOTIFIER_LIST_INITIALIZER(head) \
Paolo Bonzini31552522012-01-13 17:34:01 +010033 { QLIST_HEAD_INITIALIZER((head).notifiers) }
Anthony Liguorid1e70c52010-03-09 13:16:14 -060034
35void notifier_list_init(NotifierList *list);
36
37void notifier_list_add(NotifierList *list, Notifier *notifier);
38
Paolo Bonzini31552522012-01-13 17:34:01 +010039void notifier_remove(Notifier *notifier);
Anthony Liguorid1e70c52010-03-09 13:16:14 -060040
Jan Kiszka9e8dd452011-06-20 14:06:26 +020041void notifier_list_notify(NotifierList *list, void *data);
Anthony Liguorid1e70c52010-03-09 13:16:14 -060042
43#endif