[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 1/5] notifiers: add support for async notifi

From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [RFC PATCH 1/5] notifiers: add support for async notifiers handlers
Date: Tue, 05 Jun 2012 10:36:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120422 Thunderbird/10.0.4


> +static void notified_complete_cb(AsyncNotifier *notifier, void *opaque)
> +{

There is no need to implement this as callback (unlike the notifier
_list_ completion callback).  Just have a public notifier_complete()
function which async notifiers are supposed to call when done.

>  void notifier_list_notify(NotifierList *list, void *data)
>  {
> -    Notifier *notifier, *next;
> +    BaseNotifier *notifier, *next;
> +    bool async = false;
> +
> +    if (notifier_list_async_waiting(list)) {

assert(!notifier_list_async_waiting(list)) ?

Silently removing entries from the wait_notifier list here is asking for
trouble.  We should have a notifier_list_cancel() function instead which
also calls Notifier->cancel() for all pending async notifiers
(implementing that can wait until we have an actual need for it).

> +struct BaseNotifier {

>  struct Notifier
>  {
> +    BaseNotifier base;
>      void (*notify)(Notifier *notifier, void *data);

> +struct AsyncNotifier {
> +    BaseNotifier base;
> +    void (*notify_async)(AsyncNotifier *notifier, void *data,
> +                         NotifiedCompletionFunc *complete_cb, void *cb_data);

I don't see a need for three types here, especially as there will be no
difference between notify() and notify_async() prototypes once the
notifier completion callback is gone.  I'd suggest to just extent Notifier.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]