qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 4/6] progressmeter: protect with a mutex


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH 4/6] progressmeter: protect with a mutex
Date: Wed, 12 May 2021 10:09:01 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

11.05.2021 15:28, Paolo Bonzini wrote:
On 10/05/21 13:28, Vladimir Sementsov-Ogievskiy wrote:


Could we instead add a c file and add the structure private? Then we'll have 
progress_new() and progress_free() APIs instead.

This way, it would be a lot simpler to control that nobady use structure fields 
directly.

I don't know...  I prefer embedding structs to heap allocation.



I agree that embedding looks better from allocation point of view.. But IMHO 
encapsulation guarantee of private structure is better feature. Especially when 
we have getter/setter methods. Even the patch itself is example: to review this 
carefully, I should somehow check that every use of the structure is updated 
(grepping the code, or maybe change field name and recompile, to catch every 
occurrence of it).. And if patch makes structure private and adds 
setters/getters, it can be reviewed without applying.

And we have to call _init/_destroy anyway, so it's not more complex to call 
_new/_free instead.

--
Best regards,
Vladimir



reply via email to

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