From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mzt3q-0007n1-SC for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:18:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mzt3m-0007lu-3K for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:18:10 -0400 Received: from [199.232.76.173] (port=58163 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mzt3l-0007lp-LS for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:18:05 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:33274) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mzt3l-0001iH-5o for qemu-devel@nongnu.org; Mon, 19 Oct 2009 10:18:05 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e38.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9JEDhmB011362 for ; Mon, 19 Oct 2009 08:13:43 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9JEHdqt213732 for ; Mon, 19 Oct 2009 08:17:42 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n9JEHdFu017802 for ; Mon, 19 Oct 2009 08:17:39 -0600 Message-ID: <4ADC7502.7030903@us.ibm.com> Date: Mon, 19 Oct 2009 09:17:38 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 06/11] qobject: add QBool type References: <1255786571-3528-1-git-send-email-aliguori@us.ibm.com> <1255786571-3528-7-git-send-email-aliguori@us.ibm.com> <20091018195007.4dbaa599@doriath> In-Reply-To: <20091018195007.4dbaa599@doriath> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel@nongnu.org Luiz Capitulino wrote: > On Sat, 17 Oct 2009 08:36:06 -0500 > Anthony Liguori wrote: > > >> We currently model as json bool as an int. This works fine on the server side >> but it means we cannot send back proper bools to the client. Introducing a >> proper QBool type fixes that. >> > > As we talked earlier today, I think it would be simpler to have QTrue, > QFalse and QNull as static objects. > > We could define that static objects get reference counting disabled, I don't > see issues in doing that and we get a very simple model. > > The big patch bellow does it, only compiled tested though. > > If you don't agree with this model, we'll have to allocate QNull objects. > Actually I would suggest a destroy() method which always resets the > refcount to 1, but then it will have the concurrency problems on threaded > applications you've mentioned. > A lot of object systems have dealt with this in various ways. The trouble with reference counting is usually thread safety. CLR goes to great lengths to make their objects reference counting thread safe and it comes at a cost. Python doesn't do anything explicit and it's one of the reasons that they're stuck with a big lock. Since I'd like to expose QObject to client libraries, having a single static instance would be pretty unfortunate as it would imply a weird locking semantics. Disabling reference counts for QNull/QBool seems unfortunate because it suggests that different semantics for certain objects. I think this is a premature optimization. I don't think we need to try and save the memory here. Regards, Anthony Liguori