From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Npied-0006bE-D5 for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:42:23 -0500 Received: from [199.232.76.173] (port=57880 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Npiec-0006aq-OQ for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:42:22 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Npieb-0001n6-Uu for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:42:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11162) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Npieb-0001mo-Gp for qemu-devel@nongnu.org; Thu, 11 Mar 2010 08:42:21 -0500 Message-ID: <4B98F32B.7070706@redhat.com> Date: Thu, 11 Mar 2010 15:42:03 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 1/7] Add support for generic notifier lists References: <1268239869-16058-1-git-send-email-aliguori@us.ibm.com> <201003111257.59828.paul@codesourcery.com> <4B98EF51.7040905@redhat.com> In-Reply-To: <4B98EF51.7040905@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Anthony Liguori , Gerd Hoffman , Paul Brook , Luiz Capitulino On 03/11/2010 03:25 PM, Paolo Bonzini wrote: > On 03/11/2010 01:57 PM, Paul Brook wrote: >> +struct QEMUNotifier >> > +{ >> > + void (*notify)(QEMUNotifier *notifier); >> > +}; >> >> I suggest combining this with QEMUBH. > > I didn't understand this suggestion exactly, but I think it's related > that I didn't understand the advantage of making QEMUNotifier a > struct. Instead of using container_of, reusing QEMUBHFunc (renamed to > QEMUCallbackFunc maybe?) in QEMUNotifierNode like this: > > struct QEMUNotifierNode { > QEMUCallbackFunc notify; > void *opaque; > QTAILQ_ENTRY(QEMUNotifierNode) node; > }; > > void qemu_notifier_list_init(QEMUNotifierList *list); > > struct QEMUNotifierNode * > qemu_notifier_list_add(QEMUNotifierList *list, > QEMUCallbackFunc notify, void *opaque); > > void qemu_notifier_list_remove(QEMUNotifierList *list, > QEMUNotifierNode *notifier); > > void qemu_notifier_list_notify(QEMUNotifierList *list); > > seems cleaner. You would place the QEMUNotifierNode in VncState in > order to do the removal later. > > I disagree. container_of() is both a little more type safe, and removes the need for an extra pointer and memory object. The caller will almost always have an object in which to embed the notifier, best to make use of it. -- error compiling committee.c: too many arguments to function