Commit 2ec10b95 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Avi Kivity
Browse files

event_notifier: add event_notifier_set



EventNotifier right now cannot be used as an inter-thread communication
primitive.  It only works if something else (the kernel) sets the eventfd.
Add a primitive to signal an EventNotifier that another thread is waiting
on.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 5d62c43a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -38,6 +38,13 @@ int event_notifier_get_fd(EventNotifier *e)
    return e->fd;
}

int event_notifier_set(EventNotifier *e)
{
    uint64_t value = 1;
    int r = write(e->fd, &value, sizeof(value));
    return r == sizeof(value);
}

int event_notifier_test_and_clear(EventNotifier *e)
{
    uint64_t value;
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ struct EventNotifier {
int event_notifier_init(EventNotifier *, int active);
void event_notifier_cleanup(EventNotifier *);
int event_notifier_get_fd(EventNotifier *);
int event_notifier_set(EventNotifier *);
int event_notifier_test_and_clear(EventNotifier *);
int event_notifier_test(EventNotifier *);