[Top][All Lists]

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

Re: [Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s...

From: Sandro Santilli
Subject: Re: [Gnash-commit] gnash ChangeLog libbase/ref_counted.h libbase/s...
Date: Sat, 30 Jun 2007 19:01:57 +0200

On Sat, Jun 30, 2007 at 04:52:53PM +0000, Sandro Santilli wrote:
> CVSROOT:      /sources/gnash
> Module name:  gnash
> Changes by:   Sandro Santilli <strk>  07/06/30 16:52:53
> Modified files:
>       .              : ChangeLog 
>       libbase        : ref_counted.h smart_ptr.h 
> Log message:
>               * libbase/ref_counted.h: remove inheritance of ref_counted
>                 from GcResource, provide temporary isReachable/setReachable
>                 to allow not reverting all GC-related additions to character
>                 definitions and other possibly GcResource objects.
>               * libbase/smart_ptr.h: have two versions of the intrusive_ptr
>                 free functions: one for GcResource (do nothing) and one
>                 for ref_counted (add/drop ref). Enable GC by default, where
>                 current version uses both RC and GC (GC only used for 
> as_object)

With this commit I splitted ref_counted and GcResource so that they are not in 
same inheritance tree. This allows us to choose which classes will be managed 
with a reference-counting model and which one with a garbage-collector one.

The rationale was to make threading safe, starting with the assumption that
the loader/parser thread should never create as_object instances. The previous
problem was that the loader thread was creating GcResource instances 
in particular) concurrently with a running GC, thus resulting in premature 
of just-created objects.
for a description of the problem.

So, with this patch, we keep character_def as a ref-counted class, as well as 
which were the ones I didn't really like to have garbage-collected.
The implementation is an hack to allow touching the less files possible. We 
still always use intrusive_ptr
for both ref_counted and GcResource classes, but the intrusive_ptr_add_ref and 
free functions will act differently based on what type they are working on: 
they do NOTHIN for GcResource
and do the normal add/drop ref calls for ref_counted.

The GNASH_USE_GC macro is now defined by default, which means as_object are 
Undefining that macro in libbase/smart_ptr.h would bring us back to ref_counted 
All the rest should be the same.

Next step would be validating this model and if we like it decide which syntax 
we want to use for
garbage collected pointers. There's technically NO NEED to store 
garbage-collected pointers into
a smart pointer, but might come handy to use a smart pointer for clarity and 
eventually reducing
errors by disallowing explicit deletion, or other similar things.

Tests welcome.


reply via email to

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