1
2
3
4
5
6
7
8
9
10
11
12
13#include "qemu/osdep.h"
14#include "qemu-common.h"
15#include "qemu/event_notifier.h"
16#include "qemu/main-loop.h"
17
18int event_notifier_init(EventNotifier *e, int active)
19{
20 e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
21 assert(e->event);
22 return 0;
23}
24
25void event_notifier_cleanup(EventNotifier *e)
26{
27 CloseHandle(e->event);
28}
29
30HANDLE event_notifier_get_handle(EventNotifier *e)
31{
32 return e->event;
33}
34
35int event_notifier_set_handler(EventNotifier *e,
36 bool is_external,
37 EventNotifierHandler *handler)
38{
39 if (handler) {
40 return qemu_add_wait_object(e->event, (IOHandler *)handler, e);
41 } else {
42 qemu_del_wait_object(e->event, (IOHandler *)handler, e);
43 return 0;
44 }
45}
46
47int event_notifier_set(EventNotifier *e)
48{
49 SetEvent(e->event);
50 return 0;
51}
52
53int event_notifier_test_and_clear(EventNotifier *e)
54{
55 int ret = WaitForSingleObject(e->event, 0);
56 if (ret == WAIT_OBJECT_0) {
57 ResetEvent(e->event);
58 return true;
59 }
60 return false;
61}
62