On 03/11/2010 02:42 PM, Avi Kivity wrote:
On 03/11/2010 03:25 PM, Paolo Bonzini wrote:
I didn't understand the advantage of making QEMUNotifier a
struct. Instead of using container_of, reusing QEMUBHFunc (renamed to
QEMUCallbackFunc maybe?) in QEMUNotifierNode [...]
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.
It doesn't remove the need for an extra memory object. Anthony's design
embeds the Notifier but not the NotifierNode. Indeed, my design does
have an extra pointer (in the NotifierNode, which grows from 3 to 4 words).
I still don't like container_of much, but maybe I'll grow my
appreciation of it with time. :-)
Paolo