olli.salli at collabora.co.uk
Tue Nov 14 01:09:37 PST 2006
On Tuesday 14 November 2006 01:21, Gary Cramblitt wrote:
> 2. Object lifetime and reference counting. After passing an object reference
> to another process via D-Bus, how do you know when the object may be
> destroyed? Typically, as is done in XPCOM, this is managed via reference
> counting. Trying to do reference counting over D-Bus is challenging.
> Performance could become a big concern.
I think I have a solution for this.
The problem is having to make each ref/unref call to the service providing the
object, right? This would cause lots of extra traffic.
Now, a client might have anything between one or a gazillion references to a
given remote object. If we would make each ref/unref to the remote service,
it would be horrendously slow. But actually, the only thing the remote service
cares about is when there are no references left at all from any client.
So, a client might implement the reference counting locally. It would tell the
remote service of the first ref, and also when the reference count reaches zero
again. The remote service would keep a list of which clients have references and
when it gets the zero references left -message from one of them, it would
remove this client from the list. The object would be dead from that onwards
from the given client's POV. The remote service would of course actually
destroy the object only when there are no more clients holding references to it.
More information about the dbus