[vlc-devel] commit: One child is one reference ( Rémi Denis-Courmont )
pdherbemont at free.fr
Sat Sep 20 23:42:28 CEST 2008
On Sat, Sep 20, 2008 at 9:33 PM, Rémi Denis-Courmont <rem at videolan.org> wrote:
> Le samedi 20 septembre 2008 22:09:40 Pierre d'Herbemont, vous avez écrit :
>> On Sat, Sep 20, 2008 at 8:17 PM, git version control <git at videolan.org>
>> > vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> |
>> > Sat Sep 20 18:48:33 2008 +0300|
>> > [559c876b10bf4391dc592cc5d21ae99124a4d5ec] | committer: Rémi
>> > Denis-Courmont
>> > One child is one reference
>> > Avoid objects being detached asynchronously too early.
>> > Side effect is that you cannot free your children in the destructor
>> > (that would be a reference loop).
>> I would yield() the child rather than the parent. Parent owns
>> children, mostly because they created the children.
> The parent needs to remain in the tree until the children is gone, for the
> sake of variables. As far as I can tell, the one and only point of the object
> tree is variables. Well, the other point is the (vomitive) vlc_object_find(),
> but that does not screw my point up anyway.
> At the moment, destructors do not release a children anyway (not very clear
> with sout-keep). An object is supposed to release its children when its
> type-specific *_Destroy() function is invoked and/or as a side effect of
> vlc_object_kill() if there is no destroy function. That is supposed to be
> done independent of the reference count of the parent.
Well, this doesn't sounds right. If the parent creates the children,
and wants to keep it during all it's life span, releasing it at its
death, it can't... Weird.
How can we remove that variables tree?
1- variables should only be inherited from libvlc object.
2- Inherited variables are set explicitly by the so-called parent when
an object is created.
3- We create variable pools. An object can be attached to a variable
pool, and a variable pool has a parent and multiple children. Hence we
replicate the object tree out of the object scope. That is:
- object owns a hard reference to its variable pool
- variable pool has no reference to its object.
- variable pool has a hard reference to its parent variable pool
- variable pool has a weak reference to its children variable pools
Object fetch their variables value from their variable pool.
I prefer 1- and 2- over 3-, but 3- may be easier to implement and
closer to what we have without messing with vlc_object_t.
More information about the vlc-devel